Fix -Wunknown-pragmas warnings

This commit is contained in:
Johannes Schmidt 2025-10-17 15:05:22 +02:00
parent 6bd89821cd
commit c55c191aba
2 changed files with 30 additions and 22 deletions

View file

@ -20,13 +20,14 @@ using namespace icinga;
* should be printed. If it looks somewhat meaningful, you can probably ignore a failure of this test case.
*/
#ifndef _MSC_VER
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC push_options
#pragma GCC optimize ("O0")
#pragma GCC optimize("O0")
#elif defined(__clang__)
#pragma clang optimize off
#else /* _MSC_VER */
#elif defined(_MSC_VER)
#pragma optimize("", off)
#endif /* _MSC_VER */
#endif
BOOST_AUTO_TEST_SUITE(base_stacktrace)
@ -66,9 +67,10 @@ BOOST_AUTO_TEST_CASE(stacktrace)
BOOST_AUTO_TEST_SUITE_END()
#ifndef _MSC_VER
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC pop_options
#elif defined(__clang__)
#pragma clang optimize on
#else /* _MSC_VER */
#elif defined(_MSC_VER)
#pragma optimize("", on)
#endif /* _MSC_VER */
#endif

View file

@ -1477,26 +1477,32 @@ void ClassCompiler::CompileStream(const std::string& path, std::istream& input,
<< "#include \"base/logger.hpp\"" << std::endl
<< "#include \"base/function.hpp\"" << std::endl
<< "#include \"base/configobject.hpp\"" << std::endl
<< "#include \"base/configtype.hpp\"" << std::endl
<< "#ifdef _MSC_VER" << std::endl
<< "#pragma warning( push )" << std::endl
<< "#pragma warning( disable : 4244 )" << std::endl
<< "#pragma warning( disable : 4800 )" << std::endl
<< "#else /* _MSC_VER */" << std::endl
<< "#pragma GCC diagnostic push" << std::endl
<< "#pragma GCC diagnostic ignored \"-Wunused-parameter\"" << std::endl
<< "#pragma GCC diagnostic ignored \"-Wunused-variable\"" << std::endl
<< "#endif /* _MSC_VER */" << std::endl << std::endl;
<< "#include \"base/configtype.hpp\"" << std::endl;
#ifdef _MSC_VER
oimpl << "#pragma warning( push )" << std::endl
<< "#pragma warning( disable : 4244 )" << std::endl
<< "#pragma warning( disable : 4800 )" << std::endl;
#elif defined(__GNUC__) && !defined(__clang__)
oimpl << "#pragma GCC diagnostic push" << std::endl
<< "#pragma GCC diagnostic ignored \"-Wunused-parameter\"" << std::endl
<< "#pragma GCC diagnostic ignored \"-Wunused-variable\"" << std::endl;
#elif defined(__clang__)
oimpl << "#pragma clang diagnostic push" << std::endl
<< "#pragma clang diagnostic ignored \"-Wunused-parameter\"" << std::endl
<< "#pragma clang diagnostic ignored \"-Wunused-variable\"" << std::endl;
#endif /* _MSC_VER */
ClassCompiler ctx(path, input, oimpl, oheader);
ctx.Compile();
oheader << "#endif /* " << guard_name << " */" << std::endl;
oimpl << "#ifdef _MSC_VER" << std::endl
<< "#pragma warning ( pop )" << std::endl
<< "#else /* _MSC_VER */" << std::endl
<< "#pragma GCC diagnostic pop" << std::endl
<< "#endif /* _MSC_VER */" << std::endl;
#ifdef _MSC_VER
oimpl << "#pragma warning ( pop )" << std::endl;
#elif defined(__GNUC__) && !defined(__clang__)
oimpl << "#pragma GCC diagnostic pop" << std::endl;
#elif defined(__clang__)
oimpl << "#pragma clang diagnostic pop" << std::endl;
#endif /* _MSC_VER */
}