我想使用配置了gcc的mex
在ubuntu中編譯C代碼。我可以順利編譯OSX中的代碼。但是,當我想在Linux中編譯它時,編譯器會在註釋行中產生錯誤//
(它可以很好地與/* */
一起工作。由於該程序包含來自第三方庫的幾個頭文件,所以我不能用/* */
替代//
。 我想知道是否有任何辦法可以繞過來克服這個問題Mex在編譯Linux中的C代碼時爲//生成錯誤
MATLAB版本:R2012b gcc版本在Linux中:4.7.2 gcc版本的OSX:4.2.1
任何幫助讚賞
編輯: 這裏是我使用編譯代碼的命令:
mex -g -largeArrayDims -ldl TDSVDHNGateway.c
這裏由MEX產生的誤差:
In file included from 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 from 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 this function)
TDSVDHNGateway.c:166:25: note: each undeclared identifier is reported only once for each function it appears in
線17在頭文件是:
//Defining index_t
typedef size_t index_t;
如果我代碼//Defining index_t
與/*Defining index_t*/
代碼將被編譯沒有問題。
你能列出編譯器錯誤嗎? – Rhs
請確定併發布'mex'用於調用'gcc'的確切命令行。我懷疑那裏有一些東西是禁用''''樣式註釋的支持(有幾個選項可以做到這一點(以及其他的東西))。 – zwol
要允許在C代碼中使用C++註釋,請調用mex,如下所示:'mex CFLAGS =「\ $ CFLAGS -Wp,-lang -c-C++ - 註釋」mymexfile.c「 – Praetorian