Files
CMake/Tests/RunCMake/Autogen/MocPredefs-check.cxx
T
Orkun Tokdemir 429a452705 Autogen: Add target's C++ standard to moc_predef.h
Generate `moc_predef.h` using the same C++ standard level that will be
used to compile the target so that the compiler's predefined macros can
be more accurately recovered.

Fixes: #24624
Qt-Issue: https://bugreports.qt.io/browse/QTBUG-110847
2023-03-30 06:41:51 -04:00

61 lines
1.8 KiB
C++

#include <iostream>
#include "check_predefs.h"
#define TO_STRING(x) TO_STRING0(x)
#define TO_STRING0(x) #x
int main()
{
int ret = 0;
#if defined(__STRICT_ANSI__)
# if !defined(CHECK___STRICT_ANSI__)
std::cout << "__STRICT_ANSI__: Expected " << TO_STRING(__STRICT_ANSI__)
<< " but it is not defined.\n";
ret = 1;
# elif __STRICT_ANSI__ != CHECK___STRICT_ANSI__
std::cout << "__STRICT_ANSI__: Expected " << TO_STRING(__STRICT_ANSI__)
<< " but got: " << TO_STRING(CHECK___STRICT_ANSI__) << "\n";
ret = 1;
# endif
#elif defined(CHECK___STRICT_ANSI__)
std::cout << "__STRICT_ANSI__: Expected undefined but got: "
<< TO_STRING(CHECK___STRICT_ANSI__) << "\n";
ret = 1;
#endif
#if defined(__cplusplus)
# if !defined(CHECK___cplusplus)
std::cout << "__cplusplus: Expected " << TO_STRING(__cplusplus)
<< " but it is not defined.\n";
ret = 1;
# elif __cplusplus != CHECK___cplusplus
std::cout << "__cplusplus: Expected " << TO_STRING(__cplusplus)
<< " but got: " << TO_STRING(CHECK___cplusplus) << "\n";
ret = 1;
# endif
#elif defined(CHECK___cplusplus)
std::cout << "__cplusplus: Expected undefined but got: "
<< TO_STRING(CHECK___cplusplus) << "\n";
ret = 1;
#endif
#if defined(_MSVC_LANG)
# if !defined(CHECK__MSVC_LANG)
std::cout << "_MSVC_LANG: Expected " << TO_STRING(_MSVC_LANG)
<< " but it is not defined.\n";
ret = 1;
# elif _MSVC_LANG != CHECK__MSVC_LANG
std::cout << "_MSVC_LANG: Expected " << TO_STRING(_MSVC_LANG)
<< " but got: " << TO_STRING(CHECK__MSVC_LANG) << "\n";
ret = 1;
# endif
#elif defined(CHECK__MSVC_LANG)
std::cout << "_MSVC_LANG: Expected undefined but got: "
<< TO_STRING(CHECK__MSVC_LANG) << "\n";
ret = 1;
#endif
return ret;
}