Mex generates error for // while compiling C code in Linux

后端 未结 1 641
庸人自扰
庸人自扰 2021-01-21 12:18

I want to compile a C code in ubuntu using mex which is configured with gcc. I can smoothly compile the code in OSX. However, when I want to compile it in Linux, th

相关标签:
1条回答
  • 2021-01-21 13:02

    From the gcc docs;

    In GNU C, you may use C++ style comments, which start with ‘//’ and continue until the end of the line. Many other C implementations allow such comments, and they are included in the 1999 C standard. However, C++ style comments are not recognized if you specify an -std option specifying a version of ISO C before C99, or -ansi (equivalent to -std=c90).

    Under Linux, by default mex adds -ansi, which disables C++ comments. Either update your mexopts file, replacing -ansi with -std=c99 or run mex with;

    mex -g -largeArrayDims -ldl CFLAGS="\$CFLAGS -std=c99" TDSVDHNGateway.c
    
    0 讨论(0)
提交回复
热议问题