mex编译错误C2440:“正在初始化":无法从"const mwSize *"转换为"const int32_t *" [英] mex compilation error C2440: 'initializing': cannot convert from 'const mwSize *' to 'const int32_t *'

查看:636
本文介绍了mex编译错误C2440:“正在初始化":无法从"const mwSize *"转换为"const int32_t *"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有C/C ++语法的经验,并且面临调整语法更改的问题.我正在尝试为libvisio2生成mex文件.我有Visual Studio 2017和Matlab 2018a.

I don't have experience with C/C++ syntax and I am facing the issue of adjusting this change of syntax. I am trying to generate the mex file for libvisio2. I have visual studio 2017 and 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中的行为:

where the lines in the file matcherMex.cpp are:

 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]};

任何帮助将不胜感激,谢谢

Any help would be appreciated , Thanks

推荐答案

编译时,您需要传递

When compiling, you need to pass the -compatibleArrayDims to the mex function.

默认情况下,MEX文件以数组索引和大小以64位整数存储的方式编译(这是MATLAB原生存储它们的方式).在过去,大概是在编写代码时,它们是32位整数.给定的编译器标志将使MATLAB自动为您转换这些变量的类型(并希望在数组大小太大而无法容纳32位整数的情况下引发错误).

By default, MEX-files are compiled in a mode where array indices and sizes are stored in 64-bit integers (this is how MATLAB stores them natively). Back in the old days, presumably when your code was written, they were 32-bit integers. The given compiler flag will make MATLAB automatically convert the types of these variables for you (and hopefully throw an error if the array size is too large to fit in a 32-bit integer).

这篇关于mex编译错误C2440:“正在初始化":无法从"const mwSize *"转换为"const int32_t *"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆