【问题标题】:mex compile error: expected expression error at Matlab datatype and functionmex 编译错误:Matlab 数据类型和函数的预期表达式错误
【发布时间】:2013-02-22 13:46:25
【问题描述】:

我是在 linux 上开始 mex,所以我从下面这个小代码开始并尝试编译:

#include "mex.h"

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{ 
    mxArray *inputArrayData;     // array for input array pointers  
}

但是我的编译结果是:

>> mex firsttry.c
firsttry.c: In function ‘mexFunction’:
firsttry.c:5: error: expected expression before '/' token

我尝试了其他一些东西,似乎在涉及 matlab 数据和函数定义的所有行都会出现这个“预期表达式”错误。这里可能出了什么问题?

【问题讨论】:

    标签: matlab error-handling compiler-errors mex


    【解决方案1】:

    您的文件具有扩展名 .c,但您使用的是 C++ 样式的 cmets(由 // 引入)。将你的文件重命名为firsttry.cpp,然后调用

    >> mex firsttry.cpp
    

    【讨论】:

      【解决方案2】:

      其实标准C89只有“/*...*/”注释,mex编译器可以使用c编译器只支持C89。 要解决此问题,只需将“//...”注释替换为“/*...*/”格式即可。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-06-19
        • 1970-01-01
        • 2016-06-19
        • 1970-01-01
        • 2019-10-30
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多