【发布时间】:2015-01-27 16:35:13
【问题描述】:
我正在编写一个将 C 代码链接到 matlab 的 mex 文件。
这是我的简单 mex 文件,它什么也不做,编译得很好。
#include "mex.h"
#ifndef N
#define N 100
#endif
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
/*validate input/output arguments */
}
但是如果我改变评论,像这样:
#include "mex.h"
#ifndef N
#define N 100
#endif
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
//validate input/output arguments
}
然后我收到以下错误:
>> mex mexcallingmatlab.c
Building with 'gcc'.
Warning: You are using gcc version '4.8.2'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'. For a list of currently supported
compilers see: http://www.mathworks.com/support/compilers/current_release.
Warning: You are using gcc version '4.8.2-19ubuntu1)'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'. For a list of currently
supported compilers see: http://www.mathworks.com/support/compilers/current_release.
Error using mex
/home/dkumar/Mex_Codes_DKU/Mex_C_Codes_DKU2/mexcallingmatlab.c: In function ‘mexFunction’:
/home/dkumar/Mex_Codes_DKU/Mex_C_Codes_DKU2/mexcallingmatlab.c:9:5: error: expected expression before ‘/’ token
// validate input/output arguments */
^
另外,如果我将其中一个文件保存为 C++ 文件,那么无论我使用 // 还是 /* .... */.
有人能告诉我为什么“//”不能用于评论吗?
【问题讨论】: