Skip to content

Commit 06cdb24

Browse files
committed
Move C4251 suppression entirely into the header
The macro function should be populated in the header itself, because not only are there more compilers on Windows than just MSVC, but this header gets installed, so the check needs to happen in the consuming code. The check for __ICL is taken from the Hedley library, which makes this suppression exclude the Intel compiler on Windows. I don't have the Intel compiler to check whether this is correct.
1 parent 6bd4eac commit 06cdb24

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

cmake-init/templates/common/cmake/variables.cmake

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ endif()
1212
{if suppress}# ---- Suppress C4251 on Windows ----
1313

1414
# Please see include/%(name)s/%(name)s.hpp for more details
15-
set(pragma_suppress_c4251 "#define %(uc_name)s_SUPPRESS_C4251")
16-
if(MSVC)
17-
string(APPEND pragma_suppress_c4251 [[ _Pragma("warning(suppress:4251)")]])
18-
endif()
15+
set(pragma_suppress_c4251 "
16+
/* This needs to suppress only for MSVC */
17+
#if defined(_MSC_VER) && !defined(__ICL)
18+
# define %(uc_name)s_SUPPRESS_C4251 _Pragma(\"warning(suppress:4251)\")
19+
#else
20+
# define %(uc_name)s_SUPPRESS_C4251
21+
#endif
22+
")
1923

2024
{end}# ---- Warning guard ----
2125

0 commit comments

Comments
 (0)