NS_LOG and templates (multiple declarations of ns3::g_log)

159 views
Skip to first unread message

Chris Facchini

unread,
Jan 26, 2011, 10:52:30 AM1/26/11
to ns-3-users
Hi,

Is it possible to have NS_LOG facilities in templated classes?

The problem is, in case of a templated class I have to define class
methods in the header file (gcc doesn't support the 'export' keyword).

So, when I try to add NS_LOG_COMPONENT_DEFINE("CompName") in the .h
file, the compiler complains that g_log has been already declared
somewhere else (which is true, but for other components).
Errors go like this:
../src/contrib/cogent/variable.cc:17: error: redefinition of
‘ns3::LogComponent ns3::g_log’
../src/contrib/cogent/data.h:51: error: ‘ns3::LogComponent ns3::g_log’
previously declared here
../src/contrib/cogent/acting-variable.cc:17: error: redefinition of
‘ns3::LogComponent ns3::g_log’
../src/contrib/cogent/data.h:51: error: ‘ns3::LogComponent ns3::g_log’
previously declared here

Any idea how to solve this mystery?

TIA,
Chris

Taral Shah

unread,
Feb 26, 2011, 8:56:04 PM2/26/11
to ns-3-...@googlegroups.com
Hi ,

You have to include NS_LOG_COMPONENT_DEFINE("MyExample") in your code.

Taral


--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To post to this group, send email to ns-3-...@googlegroups.com.
To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.


Mathieu Lacage

unread,
Feb 28, 2011, 3:00:26 AM2/28/11
to ns-3-...@googlegroups.com, Chris Facchini
On Wed, Jan 26, 2011 at 16:52, Chris Facchini <c.fac...@gmail.com> wrote:

> Is it possible to have NS_LOG facilities in templated classes?

no.

Mathieu
--
Mathieu Lacage <mathieu...@gmail.com>

Reply all
Reply to author
Forward
0 new messages