Ubuntu14.04下ns-2.35的OLSR问题求助:补丁安装后ntohl重定义警告
Fixing ntohl Redefinition Warning After Applying umolsr Patch to ns-2.35 on Ubuntu 14.04
Hey there, let's sort out this ntohl redefinition warning you're facing after installing the umolsr patch. Here's the breakdown of the issue and how to fix it:
Why the Warning Occurs
The umolsr-ns235_v1.0-2014.patch adds an incorrect custom definition of the ntohl macro in the file dymoum/ns/dymo_um.h:
#define ntohl(x) x ^
But your system's standard library already defines ntohl correctly in /usr/include/netinet/in.h as a proper byte-swapping function (__bswap_32(x)). This duplicate definition triggers the compiler warning.
Step-by-Step Solution
- Open the conflicting header file with your preferred editor (we'll use
vimhere):vim /home/uday/ns-allinone-2.35/ns-2.35/dymoum/ns/dymo_um.h - Remove or comment out the faulty macro:
Locate the line#define ntohl(x) x ^and either delete it entirely, or comment it out like this:
Note: The original// #define ntohl(x) x ^x ^definition is likely a bug—it doesn't perform valid network-to-host byte order conversion. Removing it is the safest choice, as your system's standardntohlimplementation will handle this correctly.
If you want a more cautious approach (in case the patch expects this macro in some edge case), wrap it in a conditional check to avoid redefining an existing macro:#ifndef ntohl #define ntohl(x) x ^ #endif - Recompile ns-2.35 to apply the fix:
Navigate back to your ns-2.35 directory and run these commands:cd /home/uday/ns-allinone-2.35/ns-2.35 make clean make make install
This should resolve the redefinition warning and let your patched ns-2.35 build without issues.
内容的提问来源于stack exchange,提问作者Uday Kumar Manchikatla
相关产品推荐
相关产品推荐

