MATLAB: Using c++ style comments in mex files.

MATLABmex

I'm testing simple mex functions today and I would like to add some comments. However, I noticed:
  1. If my comments are surrounded by "/* \*/", namely, /*comments*/, the compilation of mex file works fine.
  2. But if my comments are commented in the way using "//", namely, //comments, the compilation fails.
Can anybody help to explain why it is so? Does that mean, I'm not able to write comments in the way of "//comments" in Matlab mex files?

Best Answer

While the LCC compiler shipped with Matlab, modern LCC versions, Borland BCC, OpenWatcom, MSVC und Intel compilers understand the C99 comment style, the GCC compiler needs to enable them explicitely on Linux:
mex('CFLAGS="\$CFLAGS -std=c99"', 'File.c')
Related Question