diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index a40ad42fd..9fc456596 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -125,18 +125,10 @@ void CmdLineParser::printError(const std::string &message) printMessage("error: " + message); } -#if defined(_WIN64) || defined(_WIN32) -bool CmdLineParser::SHOW_DEF_PLATFORM_MSG = true; -#endif - // TODO: normalize/simplify/native all path parameters // TODO: error out on all missing given files/paths bool CmdLineParser::parseFromArgs(int argc, const char* const argv[]) { -#if defined(_WIN64) || defined(_WIN32) - bool default_platform = true; -#endif - bool def = false; bool maxconfigs = false; @@ -632,10 +624,6 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[]) return false; } -#if defined(_WIN64) || defined(_WIN32) - default_platform = false; -#endif - // TODO: remove // these are loaded via external files and thus have Settings::PlatformFile set instead. // override the type so they behave like the regular platforms. @@ -1057,14 +1045,6 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[]) return true; } -#if defined(_WIN64) - if (SHOW_DEF_PLATFORM_MSG && default_platform && !mSettings.quiet) - printMessage("Windows 64-bit binaries currently default to the 'win64' platform. Starting with Cppcheck 2.13 they will default to 'native' instead. Please specify '--platform=win64' explicitly if you rely on this."); -#elif defined(_WIN32) - if (SHOW_DEF_PLATFORM_MSG && default_platform && !mSettings.quiet) - printMessage("Windows 32-bit binaries currently default to the 'win32A' platform. Starting with Cppcheck 2.13 they will default to 'native' instead. Please specify '--platform=win32A' explicitly if you rely on this."); -#endif - // Print error only if we have "real" command and expect files if (!mExitAfterPrint && mPathNames.empty() && mSettings.project.fileSettings.empty()) { printError("no C or C++ source files found."); diff --git a/cli/cmdlineparser.h b/cli/cmdlineparser.h index 2cd5df1cd..5ebf56a5b 100644 --- a/cli/cmdlineparser.h +++ b/cli/cmdlineparser.h @@ -99,11 +99,6 @@ public: return mIgnoredPaths; } -#if defined(_WIN64) || defined(_WIN32) - // temporary variable to "un-break" tests - static bool SHOW_DEF_PLATFORM_MSG; -#endif - protected: /** diff --git a/lib/platform.cpp b/lib/platform.cpp index cf6235c90..f2a04ba80 100644 --- a/lib/platform.cpp +++ b/lib/platform.cpp @@ -29,14 +29,7 @@ cppcheck::Platform::Platform() { - // This assumes the code you are checking is for the same architecture this is compiled on. -#if defined(_WIN64) - set(Type::Win64); -#elif defined(_WIN32) - set(Type::Win32A); -#else set(Type::Native); -#endif } diff --git a/releasenotes.txt b/releasenotes.txt index 8f5a8c5d5..945e66873 100644 --- a/releasenotes.txt +++ b/releasenotes.txt @@ -13,4 +13,4 @@ Changed interface: - Other: -- +- Windows builds now default to the `native` platform instead of `win32A` or `win64`. Please specify it explicitly if you depedent on it. diff --git a/test/cli/test-helloworld.py b/test/cli/test-helloworld.py index 211271368..6c5827293 100644 --- a/test/cli/test-helloworld.py +++ b/test/cli/test-helloworld.py @@ -78,7 +78,7 @@ def test_addon_absolute_path(): def test_addon_relative_path(): prjpath = getRelativeProjectPath() - ret, stdout, stderr = cppcheck(['--platform=native', '--addon=misra', '--enable=style', '--template=cppcheck1', prjpath]) + ret, stdout, stderr = cppcheck(['--addon=misra', '--enable=style', '--template=cppcheck1', prjpath]) filename = os.path.join(prjpath, 'main.c') assert ret == 0, stdout assert stdout == ('Checking %s ...\n' @@ -89,7 +89,7 @@ def test_addon_relative_path(): def test_addon_with_gui_project(): project_file = 'helloworld/test.cppcheck' create_gui_project_file(project_file, paths=['.'], addon='misra') - ret, stdout, stderr = cppcheck(['--platform=native', '--template=cppcheck1', '--enable=style', '--project=' + project_file]) + ret, stdout, stderr = cppcheck(['--template=cppcheck1', '--enable=style', '--project=' + project_file]) filename = os.path.join('helloworld', 'main.c') assert ret == 0, stdout assert stdout == 'Checking %s ...\n' % filename diff --git a/test/cli/test-more-projects.py b/test/cli/test-more-projects.py index b2945df77..ed3660beb 100644 --- a/test/cli/test-more-projects.py +++ b/test/cli/test-more-projects.py @@ -74,7 +74,7 @@ def test_project_custom_platform(tmpdir): with open(os.path.join(tmpdir, '1.c'), 'wt') as f: f.write("int x;") - ret, stdout, stderr = cppcheck(['--platform=native', '--project=' + project_file, '--template=cppcheck1', '-q']) + ret, stdout, stderr = cppcheck(['--project=' + project_file, '--template=cppcheck1', '-q']) assert ret == 0, stdout assert stdout == '' assert stderr == '' @@ -89,7 +89,7 @@ def test_project_empty_platform(tmpdir): with open(os.path.join(tmpdir, '1.c'), 'wt') as f: f.write("int x;") - ret, stdout, stderr = cppcheck(['--platform=native', '--project=' + project_file, '--template=cppcheck1', '-q']) + ret, stdout, stderr = cppcheck(['--project=' + project_file, '--template=cppcheck1', '-q']) assert ret == 0, stdout assert stdout == '' assert stderr == '' @@ -104,7 +104,7 @@ def test_project_unspecified_platform(tmpdir): with open(os.path.join(tmpdir, '1.c'), 'wt') as f: f.write("int x;") - ret, stdout, stderr = cppcheck(['--platform=native', '--project=' + project_file, '--template=cppcheck1', '-q']) + ret, stdout, stderr = cppcheck(['--project=' + project_file, '--template=cppcheck1', '-q']) assert ret == 0, stdout assert stdout == "cppcheck: 'Unspecified' is a deprecated platform type and will be removed in Cppcheck 2.14. Please use 'unspecified' instead.\n" assert stderr == '' @@ -209,7 +209,7 @@ def test_project_empty_fields(tmpdir): """) - ret, stdout, stderr = cppcheck(['--platform=native', '--project=' + project_file, '--template=cppcheck1']) + ret, stdout, stderr = cppcheck(['--project=' + project_file, '--template=cppcheck1']) assert ret == 1, stdout # do not crash assert stdout == 'cppcheck: error: no C or C++ source files found.\n' assert stderr == '' diff --git a/test/cli/test-other.py b/test/cli/test-other.py index 2d58b2584..b5fbccb9f 100644 --- a/test/cli/test-other.py +++ b/test/cli/test-other.py @@ -71,7 +71,7 @@ def test_missing_include_inline_suppr(tmpdir): def test_invalid_library(tmpdir): - args = ['--library=none', '--library=posix', '--library=none2', '--platform=native', 'file.c'] + args = ['--library=none', '--library=posix', '--library=none2', 'file.c'] exitcode, stdout, stderr = cppcheck(args) assert exitcode == 1 @@ -85,7 +85,7 @@ def test_message_j(tmpdir): with open(test_file, 'wt') as f: f.write("") - args = ['-j2', '--platform=native', test_file] + args = ['-j2', test_file] _, stdout, _ = cppcheck(args) assert stdout == "Checking {} ...\n".format(test_file) # we were adding stray \0 characters at the end @@ -102,7 +102,7 @@ def test_progress(tmpdir): } """) - args = ['--report-progress=0', '--enable=all', '--inconclusive', '--platform=native', test_file] + args = ['--report-progress=0', '--enable=all', '--inconclusive', test_file] exitcode, stdout, stderr = cppcheck(args) assert exitcode == 0 @@ -135,7 +135,7 @@ def test_progress_j(tmpdir): } """) - args = ['--report-progress=0', '--enable=all', '--inconclusive', '-j2', '--disable=unusedFunction', '--platform=native', test_file] + args = ['--report-progress=0', '--enable=all', '--inconclusive', '-j2', '--disable=unusedFunction', test_file] exitcode, stdout, stderr = cppcheck(args) assert exitcode == 0 diff --git a/test/fixture.cpp b/test/fixture.cpp index af1860169..7b2841316 100644 --- a/test/fixture.cpp +++ b/test/fixture.cpp @@ -421,9 +421,8 @@ TestFixture::SettingsBuilder& TestFixture::SettingsBuilder::platform(cppcheck::P { const std::string platformStr = cppcheck::Platform::toString(type); - // TODO: the default platform differs between Windows and Linux - //if (REDUNDANT_CHECK && settings.platform.type == type) - // throw std::runtime_error("redundant setting: platform (" + platformStr + ")"); + if (REDUNDANT_CHECK && settings.platform.type == type) + throw std::runtime_error("redundant setting: platform (" + platformStr + ")"); std::string errstr; // TODO: exename is not yet set diff --git a/test/testcmdlineparser.cpp b/test/testcmdlineparser.cpp index d1f41d455..e5593f6a0 100644 --- a/test/testcmdlineparser.cpp +++ b/test/testcmdlineparser.cpp @@ -40,17 +40,7 @@ class TestCmdlineParser : public TestFixture { public: TestCmdlineParser() : TestFixture("TestCmdlineParser") - { -#if defined(_WIN64) || defined(_WIN32) - CmdLineParser::SHOW_DEF_PLATFORM_MSG = false; -#endif - } - - ~TestCmdlineParser() override { -#if defined(_WIN64) || defined(_WIN32) - CmdLineParser::SHOW_DEF_PLATFORM_MSG = true; -#endif - } + {} private: std::unique_ptr settings; @@ -169,10 +159,6 @@ private: TEST_CASE(platformUnspecified); TEST_CASE(platformPlatformFile); TEST_CASE(platformUnknown); -#if defined(_WIN64) || defined(_WIN32) - TEST_CASE(platformDefault); - TEST_CASE(platformDefault2); -#endif TEST_CASE(plistEmpty); TEST_CASE(plistDoesNotExist); TEST_CASE(suppressionsOld); @@ -1237,39 +1223,6 @@ private: ASSERT_EQUALS("cppcheck: error: unrecognized platform: 'win128'.\n", GET_REDIRECT_OUTPUT); } -#if defined(_WIN64) || defined(_WIN32) - void platformDefault() { - REDIRECT; - - CmdLineParser::SHOW_DEF_PLATFORM_MSG = true; - - const char * const argv[] = {"cppcheck", "file.cpp"}; - ASSERT(parser->parseFromArgs(2, argv)); -#if defined(_WIN64) - ASSERT_EQUALS(cppcheck::Platform::Type::Win64, settings->platform.type); - ASSERT_EQUALS("cppcheck: Windows 64-bit binaries currently default to the 'win64' platform. Starting with Cppcheck 2.13 they will default to 'native' instead. Please specify '--platform=win64' explicitly if you rely on this.\n", GET_REDIRECT_OUTPUT); -#elif defined(_WIN32) - ASSERT_EQUALS(cppcheck::Platform::Type::Win32A, settings->platform.type); - ASSERT_EQUALS("cppcheck: Windows 32-bit binaries currently default to the 'win32A' platform. Starting with Cppcheck 2.13 they will default to 'native' instead. Please specify '--platform=win32A' explicitly if you rely on this.\n", GET_REDIRECT_OUTPUT); -#endif - - CmdLineParser::SHOW_DEF_PLATFORM_MSG = false; - } - - void platformDefault2() { - REDIRECT; - - CmdLineParser::SHOW_DEF_PLATFORM_MSG = true; - - const char * const argv[] = {"cppcheck", "--platform=unix64", "file.cpp"}; - ASSERT(parser->parseFromArgs(3, argv)); - ASSERT_EQUALS(cppcheck::Platform::Type::Unix64, settings->platform.type); - ASSERT_EQUALS("", GET_REDIRECT_OUTPUT); - - CmdLineParser::SHOW_DEF_PLATFORM_MSG = false; - } -#endif - void plistEmpty() { REDIRECT; const char * const argv[] = {"cppcheck", "--plist-output=", "file.cpp"}; diff --git a/test/testcondition.cpp b/test/testcondition.cpp index f903dc7a4..90458d433 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -38,8 +38,8 @@ public: TestCondition() : TestFixture("TestCondition") {} private: - const Settings settings0 = settingsBuilder().library("qt.cfg").library("std.cfg").severity(Severity::style).severity(Severity::warning).platform(cppcheck::Platform::Type::Native).build(); - Settings settings1 = settingsBuilder().severity(Severity::style).severity(Severity::warning).platform(cppcheck::Platform::Type::Native).build(); + const Settings settings0 = settingsBuilder().library("qt.cfg").library("std.cfg").severity(Severity::style).severity(Severity::warning).build(); + Settings settings1 = settingsBuilder().severity(Severity::style).severity(Severity::warning).build(); void run() override { const char cfg[] = "\n" diff --git a/test/testplatform.cpp b/test/testplatform.cpp index b7d356701..7dbb24789 100644 --- a/test/testplatform.cpp +++ b/test/testplatform.cpp @@ -388,15 +388,9 @@ private: ASSERT(!readPlatform(platform, xmldata)); } - void default_platform() { + void default_platform() const { cppcheck::Platform platform; -#if defined(_WIN64) - ASSERT_EQUALS(cppcheck::Platform::Type::Win64, platform.type); -#elif defined(_WIN32) - ASSERT_EQUALS(cppcheck::Platform::Type::Win32A, platform.type); -#else ASSERT_EQUALS(cppcheck::Platform::Type::Native, platform.type); -#endif } };