diff --git a/src/hammer.h b/src/hammer.h index 50b3de5c939e94084f73499b031962029104c136..95f8c981401f02d29c27926e784058ac44162d4d 100644 --- a/src/hammer.h +++ b/src/hammer.h @@ -17,6 +17,13 @@ #ifndef HAMMER_HAMMER__H #define HAMMER_HAMMER__H + +#if defined(__clang__) || defined(__GNUC__) +#define H_GCC_ATTRIBUTE(x) __attribute__(x) +#else +#define H_GCC_ATTRIBUTE(x) +#endif + #ifndef HAMMER_INTERNAL__NO_STDARG_H #include <stdarg.h> #endif // HAMMER_INTERNAL__NO_STDARG_H @@ -434,7 +441,7 @@ HAMMER_FN_DECL_NOARG(HParser*, h_nothing_p); * * Result token type: TT_SEQUENCE */ -HAMMER_FN_DECL_VARARGS_ATTR(__attribute__((sentinel)), HParser*, h_sequence, HParser* p); +HAMMER_FN_DECL_VARARGS_ATTR(H_GCC_ATTRIBUTE((sentinel)), HParser*, h_sequence, HParser* p); /** * Given an array of parsers, p_array, apply each parser in order. The @@ -443,7 +450,7 @@ HAMMER_FN_DECL_VARARGS_ATTR(__attribute__((sentinel)), HParser*, h_sequence, HPa * * Result token type: The type of the first successful parser's result. */ -HAMMER_FN_DECL_VARARGS_ATTR(__attribute__((sentinel)), HParser*, h_choice, HParser* p); +HAMMER_FN_DECL_VARARGS_ATTR(H_GCC_ATTRIBUTE((sentinel)), HParser*, h_choice, HParser* p); /** * Given a null-terminated list of parsers, match a permutation phrase of these @@ -469,7 +476,7 @@ HAMMER_FN_DECL_VARARGS_ATTR(__attribute__((sentinel)), HParser*, h_choice, HPars * * Result token type: TT_SEQUENCE */ -HAMMER_FN_DECL_VARARGS_ATTR(__attribute__((sentinel)), HParser*, h_permutation, HParser* p); +HAMMER_FN_DECL_VARARGS_ATTR(H_GCC_ATTRIBUTE((sentinel)), HParser*, h_permutation, HParser* p); /** * Given two parsers, p1 and p2, this parser succeeds in the following diff --git a/tools/windows/clvars.bat b/tools/windows/clvars.bat index 4f63bd17044a2459a542b7a895e2f6f7fef3d2dc..ba5490067b7842e3bf36071da3ec0a3096ed7a76 100644 --- a/tools/windows/clvars.bat +++ b/tools/windows/clvars.bat @@ -19,6 +19,9 @@ set WARNINGS=%WARNINGS% -wd4200 REM c4204 (non-constant aggregate initializers) ressembles C99 support set WARNINGS=%WARNINGS% -wd4204 +REM c4201 (anonymous unions) ressembles C11 support +set WARNINGS=%WARNINGS% -wd4201 + REM c4820 (warnings about padding) is not useful set WARNINGS=%WARNINGS% -wd4820