Bug 1551 - NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: core
ns-3-dev
Mac Intel Mac OS
: P5 enhancement
Assigned To: Mathieu Lacage
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-12-12 00:04 EST by Tom Henderson
Modified: 2014-09-26 18:54 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Henderson 2012-12-12 00:04:23 EST
Peter discovered that we have quite a few instances of NS_LOG_COMPONENT_DEFINE() within namespace ns3, instead of outside.

Should this be aligned across the codebase?  Does it matter?  What was the original motivation for keeping it outside the ns3 namespace?
Comment 1 Mathieu Lacage 2012-12-12 03:56:09 EST
(In reply to comment #0)
> Peter discovered that we have quite a few instances of
> NS_LOG_COMPONENT_DEFINE() within namespace ns3, instead of outside.
> 
> Should this be aligned across the codebase?  Does it matter?  What was the
> original motivation for keeping it outside the ns3 namespace?

It does not matter. The code of the macro was carefully written to allow one usage or the other.

I do not mind enforcing this across the codebase but I am tired of the automatic style police. Can we make it a policy that whenever we want to enforce a style across the codebase, we enforce it whenever we touch the relevant file for other reasons ? It will help avoid mindless search and replace games that can be harmful if you do not understand the code you are modifying.
Comment 2 Peter Barnes 2014-09-26 15:45:40 EDT
Commit: 597a9ec89e60
http://code.nsnam.org/ns-3-dev/rev/597a9ec89e60
Comment 3 Tommaso Pecorella 2014-09-26 16:15:26 EDT
moving the macro outside ns3 namespace raises a MacOS error...

[1463/2253] cxx: src/config-store/model/gtk-config-store.cc -> build/src/config-store/model/gtk-config-store.cc.1.o
../src/config-store/model/gtk-config-store.cc:27:1: error: redefinition of 'g_log' as different kind of symbol
NS_LOG_COMPONENT_DEFINE ("GtkconfigStore");
^
./ns3/log.h:171:28: note: expanded from macro 'NS_LOG_COMPONENT_DEFINE'
  static ns3::LogComponent g_log = ns3::LogComponent (name)
                           ^
/opt/local/include/glib-2.0/glib/gmessages.h:101:17: note: previous definition is here
void            g_log                   (const gchar    *log_domain,
                ^
1 error generated.

I'd say that it's safer to move all of them inside the namespace, rather than outside.
Comment 4 Peter Barnes 2014-09-26 16:19:21 EDT
Lovely...

Actually, stylistically I prefer it inside namespace ns3, but that's not what the docs say.

Alright, I'll update the docs and put them all inside.
Comment 5 Peter Barnes 2014-09-26 18:54:18 EDT
Fixed the other way (NS_LOG_COMPONENT_DEFINE inside namespace ns3)

Updated docs.

Commit: 2d29fee2b7b8

http://code.nsnam.org/ns-3-dev/rev/2d29fee2b7b8