Skip to content

Commit cb808e2

Browse files
committed
Fix detection of TROMPELOEIL_HAS_VA_OPT for MSVC
Only the new conformant MSVC preprocessor (_MSVC_TRADITIONAL==0) ever has __VA_OPT__. This became avaialble with Visual Studio 16.6, but only if running in /std:c++20 or /std:c++latest mode (i.e. _MSVC_LANG > c++17). - https://devblogs.microsoft.com/cppblog/announcing-full-support-for-a-c-c-conformant-preprocessor-in-msvc/ Starting with Visual Studio 17.10, it is now enabled regardless of /std This was changed to better match the behavaior of GCC and clang, which also loosened up their checks: - https://developercommunity.visualstudio.com/t/Zc:preprocessor-__VA_OPT__-is-not-enabl/10205604 - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98859 (GCC 13 and up allow __VA_OPT__ in -std=c2x as well as -std=c++20) - https://reviews.llvm.org/D91913 (clang 12 and up allow __VA_OPT__ regardless of c/c++ standard) The MSVC traditional preprocessor (_MSVC_TRADITIONAL defined and nonzero) never supports __VA_OPT__, regardless of MSVC or c++ standard version.
1 parent dcb489c commit cb808e2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

include/trompeloeil/mock.hpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,15 @@
122122
#define TROMPELOEIL_NOT_IMPLEMENTED(...) __VA_ARGS__
123123
#endif
124124

125-
#if defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL==0
126-
# if _MSC_VER >= 1940
127-
# define TROMPELOEIL_HAS_VA_OPT 1
128-
# else
129-
# define TROMPELOEIL_HAS_VA_OPT 0
125+
#if defined(_MSVC_TRADITIONAL)
126+
# if _MSVC_TRADITIONAL==0
127+
# if (_MSC_VER >= 1940) || ((_MSVC_VER >= 1926) && (_MSVC_LANG > 201703L))
128+
# define TROMPELOEIL_HAS_VA_OPT 1
129+
# else
130+
# define TROMPELOEIL_HAS_VA_OPT 0
131+
# endif
132+
# define TROMPELOEIL_MSVC_PREPROCESSOR 0
130133
# endif
131-
# define TROMPELOEIL_MSVC_PREPROCESSOR 0
132134
#elif __cplusplus >= 202002L
133135
# define TROMPELOEIL_HAS_VA_OPT 1
134136
#else

0 commit comments

Comments
 (0)