原文:http://www.netforum.com.cn/forum_posts.asp?TID=6188
作者:roger1218
今天升级到FC4,不过对gcc4.0有所耳闻,果然编译报错
在google上遍寻其踪迹,结果有牛人已经解决此问题,特有补丁
http://www.ececs.uc.edu/~cdmc/ucbt/src/ns228-gcc40.patch
将其放在ns-allinone目录之外,运行patch -p0 < ns228-gcc40.patch 即可搞定,再运行./install不再有错
ns228-gcc40.patch:
diff -ru ns-allinone-2.28.orig/nam-1.11/agent.h ns-allinone-2.28/nam-1.11/agent.h
--- ns-allinone-2.28.orig/nam-1.11/agent.h 2001-06-15 21:53:10.000000000 -0400
+++ ns-allinone-2.28/nam-1.11/agent.h 2005-10-07 21:51:57.000000000 -0400
@@ -70,7 +70,7 @@
inline double width() {return width_;}
inline double height() {return height_;}
virtual void findClosestCornertoPoint(double x, double y,
- double &corner_x, double &corner_y) const = NULL;
+ double &corner_x, double &corner_y) const = 0;
virtual void place(double x, double y);
void label(const char* name, int anchor);
void color(const char* name);
diff -ru ns-allinone-2.28.orig/ns-2.28/diffusion3/filter_core/filter_core.hh ns-allinone-2.28/ns-2.28/diffusion3/filter_core/filter_core.hh
--- ns-allinone-2.28.orig/ns-2.28/diffusion3/filter_core/filter_core.hh 2005-01-19 13:23:21.000000000 -0500
+++ ns-allinone-2.28/ns-2.28/diffusion3/filter_core/filter_core.hh 2005-10-07 21:51:57.000000000 -0400
@@ -99,6 +99,7 @@
class DiffusionCoreAgent;
class HashEntry;
class NeighborEntry;
+class DiffRoutingAgent;
typedef list<NeighborEntry *> NeighborList;
typedef list<Tcl_HashEntry *> HashList;
diff -ru ns-allinone-2.28.orig/ns-2.28/diffusion3/lib/nr/nr.hh ns-allinone-2.28/ns-2.28/diffusion3/lib/nr/nr.hh
--- ns-allinone-2.28.orig/ns-2.28/diffusion3/lib/nr/nr.hh 2005-01-19 13:23:21.000000000 -0500
+++ ns-allinone-2.28/ns-2.28/diffusion3/lib/nr/nr.hh 2005-10-07 21:51:57.000000000 -0400
@@ -43,7 +43,8 @@
typedef signed int int32_t;
#endif
typedef signed short int16_t;
-#if defined (sparc)
+// #if defined (sparc)
+#if defined (__SVR4) && defined (__sun)
typedef char int8_t;
#else
// Conflicts with system declaration of int8_t in Solaris
diff -ru ns-allinone-2.28.orig/ns-2.28/queue/cbq.cc ns-allinone-2.28/ns-2.28/queue/cbq.cc
--- ns-allinone-2.28.orig/ns-2.28/queue/cbq.cc 2005-01-25 17:38:47.000000000 -0500
+++ ns-allinone-2.28/ns-2.28/queue/cbq.cc 2005-10-07 21:51:57.000000000 -0400
@@ -87,6 +87,9 @@
#define LEAF_LEVEL 1 /* level# for leaves */
#define POWEROFTWO 16
+class CBQueue;
+class WRR_CBQueue;
+
class CBQClass : public Connector {
public:
friend class CBQueue;
diff -ru ns-allinone-2.28.orig/ns-2.28/tora/tora_neighbor.h ns-allinone-2.28/ns-2.28/tora/tora_neighbor.h
--- ns-allinone-2.28.orig/ns-2.28/tora/tora_neighbor.h 2005-01-19 13:23:53.000000000 -0500
+++ ns-allinone-2.28/ns-2.28/tora/tora_neighbor.h 2005-10-07 21:51:57.000000000 -0400
@@ -48,6 +48,8 @@
};
+class toraAgent;
+
class TORANeighbor {
friend class TORADest;
friend class toraAgent;
diff -ru ns-allinone-2.28.orig/ns-2.28/xcp/xcpq.cc ns-allinone-2.28/ns-2.28/xcp/xcpq.cc
--- ns-allinone-2.28.orig/ns-2.28/xcp/xcpq.cc 2005-02-03 13:29:20.000000000 -0500
+++ ns-allinone-2.28/ns-2.28/xcp/xcpq.cc 2005-10-07 21:51:57.000000000 -0400
@@ -33,6 +33,15 @@
} class_droptail_xcpq;
+const double XCPQueue::ALPHA_ = 0.4;
+const double XCPQueue::BETA_ = 0.226;
+const double XCPQueue::GAMMA_ = 0.1;
+const double XCPQueue::XCP_MAX_INTERVAL= 1.0;
+const double XCPQueue::XCP_MIN_INTERVAL= .001;
+
+const double XCPQueue::BWIDTH = 0.01;
+
+
XCPQueue::XCPQueue(): queue_timer_(NULL),
estimation_control_timer_(NULL),
rtt_timer_(NULL), effective_rtt_(0.0),
diff -ru ns-allinone-2.28.orig/ns-2.28/xcp/xcpq.h ns-allinone-2.28/ns-2.28/xcp/xcpq.h
--- ns-allinone-2.28.orig/ns-2.28/xcp/xcpq.h 2005-02-03 13:29:20.000000000 -0500
+++ ns-allinone-2.28/ns-2.28/xcp/xcpq.h 2005-10-07 21:51:57.000000000 -0400
@@ -113,11 +113,11 @@
XCPTimer* rtt_timer_;
double link_capacity_bps_;
- static const double ALPHA_ = 0.4;
- static const double BETA_ = 0.226;
- static const double GAMMA_ = 0.1;
- static const double XCP_MAX_INTERVAL= 1.0;
- static const double XCP_MIN_INTERVAL= .001;
+ static const double ALPHA_ ;
+ static const double BETA_ ;
+ static const double GAMMA_ ;
+ static const double XCP_MAX_INTERVAL;
+ static const double XCP_MIN_INTERVAL;
double Te_; // control interval
double Tq_;
@@ -141,7 +141,7 @@
double b_[BSIZE];
double t_[BSIZE];
int maxb_;
- static const double BWIDTH = 0.01;
+ static const double BWIDTH;
int min_queue_ci_;
int max_queue_ci_;
--- ns-allinone-2.28.orig/nam-1.11/agent.h 2001-06-15 21:53:10.000000000 -0400
+++ ns-allinone-2.28/nam-1.11/agent.h 2005-10-07 21:51:57.000000000 -0400
@@ -70,7 +70,7 @@
inline double width() {return width_;}
inline double height() {return height_;}
virtual void findClosestCornertoPoint(double x, double y,
- double &corner_x, double &corner_y) const = NULL;
+ double &corner_x, double &corner_y) const = 0;
virtual void place(double x, double y);
void label(const char* name, int anchor);
void color(const char* name);
diff -ru ns-allinone-2.28.orig/ns-2.28/diffusion3/filter_core/filter_core.hh ns-allinone-2.28/ns-2.28/diffusion3/filter_core/filter_core.hh
--- ns-allinone-2.28.orig/ns-2.28/diffusion3/filter_core/filter_core.hh 2005-01-19 13:23:21.000000000 -0500
+++ ns-allinone-2.28/ns-2.28/diffusion3/filter_core/filter_core.hh 2005-10-07 21:51:57.000000000 -0400
@@ -99,6 +99,7 @@
class DiffusionCoreAgent;
class HashEntry;
class NeighborEntry;
+class DiffRoutingAgent;
typedef list<NeighborEntry *> NeighborList;
typedef list<Tcl_HashEntry *> HashList;
diff -ru ns-allinone-2.28.orig/ns-2.28/diffusion3/lib/nr/nr.hh ns-allinone-2.28/ns-2.28/diffusion3/lib/nr/nr.hh
--- ns-allinone-2.28.orig/ns-2.28/diffusion3/lib/nr/nr.hh 2005-01-19 13:23:21.000000000 -0500
+++ ns-allinone-2.28/ns-2.28/diffusion3/lib/nr/nr.hh 2005-10-07 21:51:57.000000000 -0400
@@ -43,7 +43,8 @@
typedef signed int int32_t;
#endif
typedef signed short int16_t;
-#if defined (sparc)
+// #if defined (sparc)
+#if defined (__SVR4) && defined (__sun)
typedef char int8_t;
#else
// Conflicts with system declaration of int8_t in Solaris
diff -ru ns-allinone-2.28.orig/ns-2.28/queue/cbq.cc ns-allinone-2.28/ns-2.28/queue/cbq.cc
--- ns-allinone-2.28.orig/ns-2.28/queue/cbq.cc 2005-01-25 17:38:47.000000000 -0500
+++ ns-allinone-2.28/ns-2.28/queue/cbq.cc 2005-10-07 21:51:57.000000000 -0400
@@ -87,6 +87,9 @@
#define LEAF_LEVEL 1 /* level# for leaves */
#define POWEROFTWO 16
+class CBQueue;
+class WRR_CBQueue;
+
class CBQClass : public Connector {
public:
friend class CBQueue;
diff -ru ns-allinone-2.28.orig/ns-2.28/tora/tora_neighbor.h ns-allinone-2.28/ns-2.28/tora/tora_neighbor.h
--- ns-allinone-2.28.orig/ns-2.28/tora/tora_neighbor.h 2005-01-19 13:23:53.000000000 -0500
+++ ns-allinone-2.28/ns-2.28/tora/tora_neighbor.h 2005-10-07 21:51:57.000000000 -0400
@@ -48,6 +48,8 @@
};
+class toraAgent;
+
class TORANeighbor {
friend class TORADest;
friend class toraAgent;
diff -ru ns-allinone-2.28.orig/ns-2.28/xcp/xcpq.cc ns-allinone-2.28/ns-2.28/xcp/xcpq.cc
--- ns-allinone-2.28.orig/ns-2.28/xcp/xcpq.cc 2005-02-03 13:29:20.000000000 -0500
+++ ns-allinone-2.28/ns-2.28/xcp/xcpq.cc 2005-10-07 21:51:57.000000000 -0400
@@ -33,6 +33,15 @@
} class_droptail_xcpq;
+const double XCPQueue::ALPHA_ = 0.4;
+const double XCPQueue::BETA_ = 0.226;
+const double XCPQueue::GAMMA_ = 0.1;
+const double XCPQueue::XCP_MAX_INTERVAL= 1.0;
+const double XCPQueue::XCP_MIN_INTERVAL= .001;
+
+const double XCPQueue::BWIDTH = 0.01;
+
+
XCPQueue::XCPQueue(): queue_timer_(NULL),
estimation_control_timer_(NULL),
rtt_timer_(NULL), effective_rtt_(0.0),
diff -ru ns-allinone-2.28.orig/ns-2.28/xcp/xcpq.h ns-allinone-2.28/ns-2.28/xcp/xcpq.h
--- ns-allinone-2.28.orig/ns-2.28/xcp/xcpq.h 2005-02-03 13:29:20.000000000 -0500
+++ ns-allinone-2.28/ns-2.28/xcp/xcpq.h 2005-10-07 21:51:57.000000000 -0400
@@ -113,11 +113,11 @@
XCPTimer* rtt_timer_;
double link_capacity_bps_;
- static const double ALPHA_ = 0.4;
- static const double BETA_ = 0.226;
- static const double GAMMA_ = 0.1;
- static const double XCP_MAX_INTERVAL= 1.0;
- static const double XCP_MIN_INTERVAL= .001;
+ static const double ALPHA_ ;
+ static const double BETA_ ;
+ static const double GAMMA_ ;
+ static const double XCP_MAX_INTERVAL;
+ static const double XCP_MIN_INTERVAL;
double Te_; // control interval
double Tq_;
@@ -141,7 +141,7 @@
double b_[BSIZE];
double t_[BSIZE];
int maxb_;
- static const double BWIDTH = 0.01;
+ static const double BWIDTH;
int min_queue_ci_;
int max_queue_ci_;