我想用g++-4.4编译一些C ++代码(可以用windows上的Visual Studio 2012编译)。
我有这段代码,
const std::string cnw::restoreSession(const std::vector<string> &inNwsfile) { for (std::string &nwfile : inNwsfile){ // some... } }
我无法编译,因为这个错误:
CNWController.cpp:154: error: expected initializer before ':' token
你能给我一些关于如何解决这个问题的build议吗?
multithreadinglinux与windows
移植win32代码(windows.h)到linux
将Winsock移植到linux套接字
如何在Qt中将windows项目导入Ubuntu?
将c ++从linux移植到windows,'__aligned__'
FreeBSD v8.1上的/ proc / cpuinfo相当于什么?
linux和windows之间的移植工作如何?
linux中的“sysinfo.h”的Mac OS X等效头文件
为什么malloc有时不工作?
在windows上build立GnuMP库的dll的程序
您的编译器太旧,无法支持基于范围的语法。 根据GNU,它在GCC 4.6中首次得到支持。 GCC还要求你明确地要求C ++ 11的支持,在编译器上给出命令行选项-std=c++11或c++0x 。
如果你不能升级,那么你需要老同学:
for (auto it = inNwsfile.begin(); it != inNwsfile.end(); ++it) { std::string const &nwfile = *it; // const needed because inNwsfile is const //some... }
我相信在GCC 4.4中可以使用auto (只要你启用了C ++ 0x支持)就可以保存你写std::vector<string>::const_iterator 。
如果你确实需要一个非const引用vector元素,那么无论使用哪种风格的循环,都需要从函数参数中删除const 。
总结以上是内存溢出为你收集整理的错误:“:”令牌之前的预期初始值设定项全部内容,希望文章能够帮你解决错误:“:”令牌之前的预期初始值设定项所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)