编译器错误:“使用”之前应为非限定 id
Compiler error: expected unqualified-id before ‘using’
我正在尝试编译此c ++代码
template<int I> using Foo = int;
using Bar = int;
并得到这些编译器错误(g++ -c test.cpp
)
test.cpp:1:17: error: expected unqualified-id before ‘using’
template<int I> using Foo = int;
test.cpp:2:7: error: expected nested-name-specifier before ‘Bar’
using Bar = int;
我的问题是语法错误,正如此错误的大多数解决方案所表明的那样,只是不是任何典型的解决方案。
较新的(从 c++11 开始)类型别名形式的"using"在尝试使用较旧的标准修订版编译它们时也会报告此错误。 添加 g++ 选项-std=c++11
(或更高标准选项之一),让 g++ 知道它需要使用 c++11 功能编译代码。
相关文章:
- 我不断收到 [错误] ID 返回 1 退出状态错误,但看不到问题所在
- 方法内部但循环仍得到预期的不合格id错误C++
- Xcode 9.4.1 中的 Apple Mach-O 链接器 (id) 错误
- 错误:令牌 { '{' 之前应存在非限定 ID
- DCMTK 了解"DIMSE 没有有效的演示上下文 ID"错误
- C++中的"expected unqualified-id"错误是什么?
- c++ for 循环中预期的非限定 id 错误
- 在"." 令牌之前应为非限定 ID(C++ 错误)
- 预期"{"错误?以及预期的未指定 ID 错误?
- 错误:预期的非限定 ID 错误:含义和修复
- 安卓-NDK-R7C "deque.h"中的非限定 ID 错误
- 预期的不合格id错误,很可能是原因
- 意外的非限定 ID 错误
- C++中类出现预期的不合格id错误
- 出现意外的非限定id错误
- iOS中出现不合格的id错误
- XSLT到HTML的转换.Qt5中的generate-id()错误
- 不合格的id错误和井字游戏板不工作
- 传递结构体数组的预期非限定id错误
- 如何执行项目范围内的唯一id /错误代码,以便在源代码中轻松找到错误的来源