[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] What is a patch file?



Hi :
I'm using ns-2.1b7 on redhat7. When I want to compile, I face this
problem:
random.cc:51:extraneous 'int' ignored
random.cc: In function 'int random()' :
random.cc:51 declaration of 'int random()' throws different exceptions
user/include/stdlib.h:339:than previous declaration 'int random
() throw'
make : *** [random.o] Error 1
 I found a patch file for a somehow similar case in the web site but
actually I don't know if this patchfile  will solve my problem and Also
I don't know how to use a patch file.
Thanks.
Mona
 **************
# here is the soloution I've found:
Problem: In Debian Linux, ns compilation fails with an error like:

c++ -c -g -DNO_TK  -DNDEBUG -DUSE_SHM -DHAVE_LIBTCLCL1_0B5
-DHAVE_TCLCL_H
-DHAVE_LIBOTCL1_0A2 -DHAVE_OTCL_H -DHAVE_LIBTK4_2 -DHAVE_T
K_H -DHAVE_LIBTCL7_6 -DHAVE_TCL_H  -I. -I../tclcl-1.0b5
-I/usr/local/include -I/usr/include/tcl -I/usr/include/tcl  -o random.o
rand
om.cc
random.cc: In function `int random()':
random.cc:50: new declaration `int random()'
/usr/include/stdlib.h:198: ambiguates old declaration `long int
random()'
make: *** [random.o] Error 1


Solution: There seems to be differences in Linux definitions of random.
The Right Thing is to have autoconf detect the type of random, but
(since I've
not done that before) that's low on the priority list right now (code
contributions are welcome, of course---it should be easy to do this in
autoconf).

Another approach would be to use an #define which differs between Debian
and RedHat. I don't know of such a #define.

Until it's fixed the Right Way, this patch should work around the
problem:

--- random.cc~  Tue Apr 14 14:07:04 1998
+++ random.cc   Tue Apr 21 10:50:07 1998
@@ -41,11 +41,7 @@
 #include
 #include "random.h"

-#ifdef linux
-int
-#else
 long
-#endif
 random()
 {
        printf("random() called in ns.\nRandom is not portable, please
use Random::uniform() instead.\n");