Bug 1699

Summary: Compilation error due to missing header includes on some platforms (Linux)
Product: ns-3 Reporter: Alex Afanasyev <alexander.afanasyev>
Component: fd-net-deviceAssignee: alina <aquereilhac>
Status: RESOLVED DUPLICATE    
Severity: critical CC: ns-bugs
Priority: P5    
Version: ns-3-dev   
Hardware: All   
OS: Linux   

Description Alex Afanasyev 2013-06-15 13:20:40 UTC
When fd-net-device module is enabled, on soma platforms compilation fails with the following error, related to strerror:

[1038/2041] cxx: src/fd-net-device/examples/fd2fd-onoff.cc -> build/src/fd-net-device/examples/fd2fd-onoff.cc.2.o
../src/fd-net-device/helper/creator-utils.cc: In function 'void ns3::SendSocket(const char*, int, int)':
../src/fd-net-device/helper/creator-utils.cc:60:3: error: 'strerror' was not declared in this scope
../src/fd-net-device/helper/creator-utils.cc:74:3: error: 'strerror' was not declared in this scope
../src/fd-net-device/helper/creator-utils.cc:78:3: error: 'strerror' was not declared in this scope
../src/fd-net-device/helper/creator-utils.cc:170:3: error: 'strerror' was not declared in this scope


I think adding into creator-utils.h the following would solve this particular problem:

// linux man page specifies <string.h> for strerror
#include <string.h>

// OSX man page asks for <stdio.h> for strerror
#include <stdio.h>


---

At the same time I wonder, why creator-utils.h "redefines" logging commands and not using build-in NS-3 routines?..
Comment 1 alina 2013-06-16 02:00:10 UTC
(In reply to comment #0)
> When fd-net-device module is enabled, on soma platforms compilation fails with
> the following error, related to strerror:
> 
> [1038/2041] cxx: src/fd-net-device/examples/fd2fd-onoff.cc ->
> build/src/fd-net-device/examples/fd2fd-onoff.cc.2.o
> ../src/fd-net-device/helper/creator-utils.cc: In function 'void
> ns3::SendSocket(const char*, int, int)':
> ../src/fd-net-device/helper/creator-utils.cc:60:3: error: 'strerror' was not
> declared in this scope
> ../src/fd-net-device/helper/creator-utils.cc:74:3: error: 'strerror' was not
> declared in this scope
> ../src/fd-net-device/helper/creator-utils.cc:78:3: error: 'strerror' was not
> declared in this scope
> ../src/fd-net-device/helper/creator-utils.cc:170:3: error: 'strerror' was not
> declared in this scope
> 
> 
> I think adding into creator-utils.h the following would solve this particular
> problem:
> 
> // linux man page specifies <string.h> for strerror
> #include <string.h>
> 
> // OSX man page asks for <stdio.h> for strerror
> #include <stdio.h>
> 
> 
> ---
> 
> At the same time I wonder, why creator-utils.h "redefines" logging commands and
> not using build-in NS-3 routines?..

This is the same bug as reported in bug 1693. This bug was fixed in 9825:c67e13985be0, by including the cstring header in creator-utils.cc. Are you compiling the latest revision of ns-3-dev ?
Comment 2 Alex Afanasyev 2013-06-16 13:57:19 UTC
Ohh. My bad. I'm not using exactly the latest version but I did a quick search in bugzilla, as well as checked the latest commits in the repo, but managed to miss both existing bug and the fix.

However, though I still wonder why there is a need for custom logging macros...

*** This bug has been marked as a duplicate of bug 1693 ***
Comment 3 alina 2013-06-16 22:01:18 UTC
(In reply to comment #2)
> Ohh. My bad. I'm not using exactly the latest version but I did a quick search
> in bugzilla, as well as checked the latest commits in the repo, but managed to
> miss both existing bug and the fix.
> 
> However, though I still wonder why there is a need for custom logging macros...
> 
> *** This bug has been marked as a duplicate of bug 1693 ***

The need for custom logging macros arises because creator-utils.h is used by (raw socket/tap/tun) creator programs that are not directly part of ns-3. This programs are intended to be executed independently from the simulator, with root privileges, and to be short lived (just the time to create the socket or tap). The design choice taken was to add custom logging macros for the creators (even if logging macros already exist in ns-3) instead of making them depend on ns-3 core.