MATLAB: C++ comments in Mex files under Linux

c99gcclinuxmex

For many years users support problems about compiling C-sources containing C++ comments under Linux, because the automatically created mexopts file enables the -ansi style instead of the modern std=-c99 style for the GCC compiler.
Other compilers accept the C++ comments for a long time: LCC (shipped with Matlab or downloaded from the net), Borland BCC, OpenWatcom, MSVC, Intel ICC, Tiny C (TCC), PCC, …
Is there any reason not to enable the 12 year old C99 standard in the default mexopts file for the GCC under Linux?
BTW: To solve the problem, you can edit the mexopts file: replace '-ansi' by '-std=c99' or add these flags to the MEX call:
mex -O CFLAGS="\$CFLAGS -std=c99" yourfile.c

Best Answer

Probably it's the same reason they still include the silly "/fixed" option on the Fortran mexopts.bat files (which forces free-format source code to be interpreted by the compiler as fixed-format source code). It doesn't affect their sample code and they haven't had enough user complaints to motivate them to change it (which would require them to re-validate all of their sample code I presume).
Related Question