gcc - Mex generates error for // while compiling C code in Linux -
i want compile c code in ubuntu using mex
configured gcc. can smoothly compile code in osx. however, when want compile in linux, compiler generates error on comment lines starting //
(it works fine /* */
. since program includes several header files third-party libraries, cannot substitute //
/* */
. know whether there way around overcome problem.
matlab version: r2012b gcc version in linux: 4.7.2 gcc version in osx: 4.2.1
any appreciated
edit: here command use compile code:
mex -g -largearraydims -ldl tdsvdhngateway.c
here error generated mex:
in file included tdsvdhngateway.c:2:0: tds.h:17:1: error: expected identifier or ‘(’ before ‘/’ token tds.h:26:2: error: unknown type name ‘index_t’ tds.h:27:2: error: unknown type name ‘index_t’ in file included tdsvdhngateway.c:2:0: tds.h:146:3: error: unknown type name ‘index_t’ tdsvdhngateway.c:37:3: error: unknown type name ‘index_t’ tdsvdhngateway.c: in function ‘mexfunction’: tdsvdhngateway.c:166:25: error: ‘index_t’ undeclared (first use in function) tdsvdhngateway.c:166:25: note: each undeclared identifier reported once each function appears in
line 17 in header file is:
//defining index_t typedef size_t index_t;
if replace //defining index_t
/*defining index_t*/
code compiled no problem.
from the gcc docs;
in gnu c, may use c++ style comments, start ‘//’ , continue until end of line. many other c implementations allow such comments, , included in 1999 c standard. however, c++ style comments not recognized if specify -std option specifying version of iso c before c99, or -ansi (equivalent -std=c90).
under linux, default mex
adds -ansi
, disables c++ comments. either update mexopts file, replacing -ansi
-std=c99
or run mex with;
mex -g -largearraydims -ldl cflags="\$cflags -std=c99" tdsvdhngateway.c
Comments
Post a Comment