Jas*_*ase 4 c++ compiler-errors c++11 gcc4.6
我是这个问题的OP:扩展一个我得到了很好答案的课程.但是,当我尝试编译代码(稍微为我的项目重做)时,我收到以下消息(行号改为反映以下示例代码):
except.h: | 09 | expected nested-name-specifier before ‘handler_t1’
Run Code Online (Sandbox Code Playgroud)
以及更多似乎源于这条线的东西.我是C++的新手,我对答案(以及即将出现的问题)的研究已经产生了这样一个事实:微软的编译器似乎接受了代码,但符合标准的编译器却没有.
我目前拥有的代码如下:
#include <vector>
namespace except
{
// several other classes and functions which compile and work already
// (tested and verified) have been snipped out. Entire code is over
// 1000 lines.
class Error_Handler
{
public:
using handler_t1 = bool (*)(except::Logic const&);
std::vector<handler_t1> logic_handlers;
// a lot more removed because the error has already happened ...
}
}
Run Code Online (Sandbox Code Playgroud)
阅读链接问题中的代码表明(我的知识有限)它应该都可以工作.
因此,我的问题是:我需要在此声明/定义中进行哪些更改才能使用gcc进行编译(使用-std = C++ 0x进行4.6.3 64位linux编译)?
GCC 4.6.3不支持C++ 11类型别名:using handler_t1 = bool (*)(except::Logic const&);.非模板类型别名等同于typedef : typedef bool (*handler_t1)(except::Logic const&);. 替换它们,看看是否有帮助.
甚至更好,升级到更新的编译器版本.我相信这里的常规响应者倾向于写入GCC 4.8编译的语言部分.
编辑:我在答案中看到的唯一其他iffy功能是基于范围的,我相信GCC在4.6中增加了支持.用typedef替换类型别名后应该没问题.
| 归档时间: |
|
| 查看次数: |
26223 次 |
| 最近记录: |