I recently added support for Pelles C to one of my projects (Hedley (http://nemequ.github.io/hedley/)), and I noticed that "calling" _Pragma multiple times on a single line causes errors. This is particularly annoying in preprocessor macros, so here's a quick test for that:
#define FOO_DLLEXPORT \
_Pragma("warn(push)") \
_Pragma("warn(disable:2016)") \
__declspec(dllexport) \
_Pragma("warn(pop)")
FOO_DLLEXPORT
void foo(void) { }
Results in
pragmas.c(7): error #1017: Syntax error in directive.
pragmas.c(7): warning #2099: Missing type specifier; assuming 'int'.
pragmas.c(7): error #2001: Syntax error: expected ')' but found 'string constant'.
pragmas.c(7): error #2001: Syntax error: expected ';' but found '_Pragma'.
pragmas.c(7): warning #2099: Missing type specifier; assuming 'int'.
pragmas.c(7): error #2001: Syntax error: expected ')' but found 'string constant'.
pragmas.c(7): warning #2117: Old-style function definition for '_Pragma'.
pragmas.c(7): warning #2016: Use of __declspec(dllexport) requires the /Ze option; ignored.
pragmas.c(7): warning #2099: Missing type specifier; assuming 'int'.
pragmas.c(7): error #2001: Syntax error: expected ')' but found 'string constant'.
pragmas.c(8): error #2001: Syntax error: expected ';' but found 'void'.
pragmas.c(8): error #2001: Syntax error: expected ';' but found '{'.
pragmas.c(8): error #2011: Declared parameter 'foo' is missing.
pragmas.c(7): error #2011: Declared parameter '_Pragma' is missing.
error #2001: Syntax error: expected '{' but found 'end of input'.
error #2001: Syntax error: expected '}' but found 'end of input'.
On the other hand, this works:
#pragma warn(push)
#pragma warn(disable:2016)
__declspec(dllexport)
#pragma warn(pop)
void foo(void) { }
As does
_Pragma("warn(push)")
_Pragma("warn(disable:2016)")
__declspec(dllexport)
_Pragma("warn(pop)")
void foo(void) { }