https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37041
--- Comment #7 from Eric Gallager <egall at gwmail dot gwu.edu> --- (In reply to Manuel López-Ibáñez from comment #6) > (In reply to Eric Gallager from comment #5) > > #ifdef __cplusplus > > extern "C" { > > #endif > > > > /* code that is C-only */ > > This is not what extern "C" means. The code still needs to be valid C++ and > this is why -Wc++-compat would be useful here. For example, this is not > valid C++ despite being valid C, and -Wc++-compat rightly warns you about it: > > #ifdef __cplusplus > extern "C" { > #endif > /* code that is C-only */ > int and(void); > #ifdef __cplusplus > } > #endif /* __cplusplus */ > Oops, I made my example needlessly complicated. I should have just said: #ifndef __cplusplus /* code that is C-only */ int and(void); #endif /* !__cplusplus */