views:

487

answers:

1

Hello,

I'm compiling C++ code and I'd like to enable the -pedantic option.
I'm using GCC 4.0, running Xcode on Mac OS X Leopard.
It is for example possible to allow variadic macros and the long long type that are normally forbidden when using -pedantic (with -Wno-variadic-macros and -Wno-long-long). But I could not find anything to disable the "comma at end of enumerator list" warning.
Is it possible?

Thanks.

+2  A: 

A comma at the end of an enumerator is valid in C99 but not in C89, so the following will work providing your code is valid C99

gcc -std=c99 -pedantic foo.c

I'm fairly sure that it's not valid in C++ (according to g++) at all

Edit: tested this with GCC 4.2.1 on HP-UX and it works with no errors / warnings foo.c

int main(int argc, char** argv) {
    enum { A, B, };
    return 0;
}


gcc -std=c99 -pedantic foo.c
Glen
Indeed, I get a warning when "-std=c89" is used. No warning when "-std=99" is used. But I get an error if I turn foo.c into foo.cpp. That's my problem...
Guillaume
if it's a .c file then GCC uses a C compiler. If it's a .cc or .cpp file GCC uses a C++ compiler. Your code isn't legal C++, hence the error.
Glen