https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78657
Bug ID: 78657 Summary: Using macro with _Pragma gives error: '#pragma' is not allowed here Product: gcc Version: 5.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: jquinsey at entrenet dot com Target Milestone: --- The following two-line source file test.c: #define FOO _Pragma("GCC diagnostic push") 42 int foo = FOO; gives: gcc test.c -E # 1 "test.c" # 1 "<built-in>" # 1 "<command-line>" # 1 "test.c" int foo = # 2 "test.c" #pragma GCC diagnostic push # 2 "test.c" 42; gcc test.c test.c:2:1: error: expected expression before '#pragma' int foo = FOO; ^ g++ -x c++ test.c test.c:2:1: error: '#pragma' is not allowed here int foo = FOO; ^ This appears to be consistent across many versions of gcc and g++. For example, 5.4.0 from Cygwin, 5.1 from this test sample at http://ideone.com/6unk5c, and versions 4.4 through to 6.2 and 7 at https://godbolt.org/. The icc and clang compilers (from 3.2 upwards) seem handle this correctly. The text within the _Pragma doesn't seem relevant. Reversing the order of the two parts of the macro gives a slightly different error message for C: error: expected ',' or ';' before '#pragma'