c++ - mex 编译错误 C2440 : 'initializing' : cannot convert from 'const mwSize *' to 'const int32_t *'

标签 c++ matlab compiler-errors mex

我没有 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]};

如有任何帮助,我们将不胜感激,谢谢

最佳答案

编译时需要传入-compatibleArrayDimsmex 函数。

默认情况下,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/

相关文章:

c++ - 模仿 MFC 中的复选框的双态按钮

c++ - 将 shared_ptr 保存到类中的实现的设计模式和优点是什么?

matlab - 通过PCA进行特征提取

linux - 超时并终止并行 matlab 执行

c - 出现编译错误

java - 包与 Java 9 中的自动模块冲突

compiler-errors - Android studio : Error Code: -1073741819 - Using ABS, ViewPagerIndicator,FacebookSDK 无法构建项目

c++ - 使用 iostream 和指针获取段错误

c++ - 在c++中使用x86 DIV的asm block 有什么用?

matlab - 在 matlab 中查找网站中字符串的可能匹配项