How do I enable C++ styled comments in gcc while leaving ANSI enabled?
On recent releases of gcc, -ansi
is documented as being the same as -std=c89
. The new comment syntax is only available with the C99 standard, so -std=c99
would allow it.
There is also -std=gnu89
, which is the same as -std=c89
but allowing all gcc extensions (including the C++-style comment syntax, which was a GNU extension long before it was added to the standard).
Also look at the -pedantic
flag, which could give you some useful warnings.
References: