https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64332
Bug ID: 64332 Summary: gcc/g++ handles system_header differently Product: gcc Version: 4.9.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: a3at.mail at gmail dot com Created attachment 34292 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34292&action=edit warning-constructor-attribute-ignored.tgz Digging through one or compilation errors, after doing this: #define __constructor __attribute__((constructor)) I turned out that gcc/g++ have different behaviours for system_header pragma. Here is a simple example (also archived in attach): $ head *.[ch] ==> c.h <== #define __constructor __attribute__((constructor)) ==> c-impl.h <== #pragma GCC system_header typedef void (*__cb_type)(void *); int foo(__cb_type __constructor); ==> main.c <== #include "c.h" #include "c-impl.h" $ gcc -c main.c $ gcc -Wall -Wextra -Wpedantic -Wattributes -c main.c $ g++ -c main.c In file included from main.c:1:0: c.h:1:50: warning: ‘constructor’ attribute ignored [-Wattributes] #define __constructor __attribute__((constructor)) $ clang++-3.5 -c main.c clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated $ clang-3.5 -c main.c $ g++ --version g++ (Debian 4.9.1-16) 4.9.1 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Is this desired behavior?