【发布时间】:2015-10-31 03:52:42
【问题描述】:
我在使用 waf 构建软件 (ns3) 时遇到此错误
In file included from ../src/internet-stack/mp-tcp-typedefs.cc:6:
../src/internet-stack/mp-tcp-typedefs.h:151: error: ISO C++ forbids declaration of ‘multiset’ with no type
../src/internet-stack/mp-tcp-typedefs.h:151: error: expected ‘;’ before ‘<’ token
In file included from ../src/internet-stack/mp-tcp-socket-impl.cc:17:
../src/internet-stack/mp-tcp-typedefs.h:151: error: ISO C++ forbids declaration of ‘multiset’ with no type
../src/internet-stack/mp-tcp-typedefs.h:151: error: expected ‘;’ before ‘<’ token
我搜索了错误,解决方案说我的 C++ 代码中可能缺少using namespace std 或#include <set>,但我的代码没有缺少这些。错误来源[mp-tcp-typedefs.h]的文件是here(第151行有错误)。
我尝试解决错误,但我仍然得到这些错误很长时间了。
我的 gcc/g++ 版本是 g++ (Ubuntu/Linaro 4.4.7-8ubuntu1) 4.4.7。
【问题讨论】:
-
确保您的 .h 文件中包含
#include <set>。 -
@Daniel 是的,.h 文件是我发布的文件,它有#include
。 -
请尝试使用
std::multiset以确保这不是名称查找问题的奇怪形式。如果可以,请尝试其他编译器。您当前使用的那个似乎遇到了某种语法误解(可能是由源代码 before 第 151 行中的问题引起的)。另一个编译器可能有更好的诊断。 -
问题不是由您显示/链接的代码引起的:melpon.org/wandbox/permlink/bj0SKMgUoHoIKrP8 所以它必须由标题引起,或者由标题的组合引起。
标签: c++ compiler-errors ns-3