+-
使用visual C编译器(Visual Studio 2010)导致变量数组大小出错.如何规避这个问题?
我遇到了一些编译c文件的麻烦,这个文件在GCC下作为以前的版本运行良好.
问题是,我使用的是变量数组大小的向量:

unsigned int howmany;
std::vector<int>* array_adresses[howmany]; 

我目前正在使用Visual-Studio 2010 C编译器来构建Matlab 64位Mex文件.
由于VC不允许我在编译时使用大小未知的数组,因此我收到以下错误消息:

错误2057:预期的常量表达式
错误2466:
错误2133:未知大小

有没有办法使用GCC编译器选项构建64位mex文件,或者在Matlab下使用不同的64位编译器构建它?

提前致谢!!

最佳答案
howmany需要保持不变,并且需要是一个定义的数量,如下所示:

const unsigned int howmany = 5;
std::vector<int>* array_adresses[howmany];

或者您可以像这样动态定义它:

unsigned int howmany = 5;
std::vector<int>* array_adresses = new std::vector<int>[howmany];
点击查看更多相关文章

转载注明原文:使用visual C编译器(Visual Studio 2010)导致变量数组大小出错.如何规避这个问题? - 乐贴网