ISO C ++禁止声明“multiset”,没有类型 [英] ISO C++ forbids declaration of ‘multiset’ with no type
问题描述
在使用waf构建软件(ns3)时遇到此错误
I am getting this error while building a software (ns3) using waf
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
我搜索错误,解决方案说可能我缺少一个使用命名空间std
或 #include< set>
在我的C ++代码,但我的代码不缺少那些。错误源自 [mp-tcp-typedefs.h]
的文件是这里(行151有错误)。
I searched for the error and the solutions say that probably I am missing a using namespace std
or #include <set>
in my C++ code, but my code is not missing those. The file where the error originates [mp-tcp-typedefs.h]
is here (Line 151 has the error).
我尝试解决错误,但仍然,我得到了很长时间了。
I tried resolving the error but still, I Am getting those for a long time now.
我的gcc / g ++版本是g ++(Ubuntu / Linaro 4.4.7-8ubuntu1)4.4.7。
My gcc/g++ version is g++ (Ubuntu/Linaro 4.4.7-8ubuntu1) 4.4.7.
推荐答案
您不应在头文件中使用命名空间std; 放置:
You should not put using namespace std;
in a header file:
您可以使用命名空间移动 来修正程式码std; / code>在你自己的命名空间中改变这个:
You can probably fix your code by moving your using namespace std;
inside your own namespace changing this:
using namespace std;
namespace ns3 {
到此:
namespace ns3 {
using namespace std;
但最好使用命名空间std; 并使用 std ::
限定所有标准符号,或者在自己的命名空间中单独声明它们。
But better to remove the using namespace std;
and qualify all your standard symbols with std::
or else declare them individually inside your own namespace.
namespace ns3 {
using std::string;
using std::list;
using std::multiset;
using std::queue;
这篇关于ISO C ++禁止声明“multiset”,没有类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!