我没有 C/C++ 语法经验,我面临着调整这种语法变化的问题。我正在尝试为 libvisio2 生成 mex 文件。我有 Visual Studio 2017 和 Matlab 2018a。
完整的错误是
D:\Libraries\libviso2\matlab\matcherMex.cpp(101): error C2440: 'initializing': cannot convert from 'const mwSize *' to
'const int32_t *'
D:\Libraries\libviso2\matlab\matcherMex.cpp(101): note: Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast
文件 matcherMex.cpp 中的行是:
99: // get pointer to left image
100: uint8_t* I1 = (uint8_t*)mxGetPr(prhs[1]);
101: const int32_t *dims1 = mxGetDimensions(prhs[1]);
102:
103: // transpose
104: uint8_t* I1_ = transpose<uint8_t>(I1,dims1);
105: int32_t dims1_[] = {dims1[1],dims1[0],dims1[1]};
如有任何帮助,我们将不胜感激,谢谢
最佳答案
编译时需要传入-compatibleArrayDims
到 mex
函数。
默认情况下,MEX 文件以数组索引和大小存储在 64 位整数中的模式进行编译(这是 MATLAB 本地存储它们的方式)。回到过去,大概当你编写代码时,它们是 32 位整数。给定的编译器标志将使 MATLAB 自动为您转换这些变量的类型(如果数组大小太大而无法容纳 32 位整数,则有望抛出错误)。
关于c++ - mex 编译错误 C2440 : 'initializing' : cannot convert from 'const mwSize *' to 'const int32_t *' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53350219/