error: conflicting declaration ‘typedef struct

1,621 views
Skip to first unread message

K' Dash

unread,
Jun 6, 2014, 2:49:16 PM6/6/14
to ns-3-...@googlegroups.com
Dear Members

I am not getting that how to resolve these errors. please help

[adnan@localhost ns-3.19]$ ./waf --run scratch/test_medeha_adhoc
Waf: Entering directory `/home/adnan/porting/ns-allinone-3.19/ns-3.19/build'
[ 408/1754] install-ns3-header: src/medeha/model/EID_home_server_application.h -> build/ns3/EID_home_server_application.h
[ 821/1754] cxx: scratch/IS-Based.cc -> build/scratch/IS-Based.cc.10.o
[ 826/1754] cxx: scratch/test_medeha_adhoc.cc -> build/scratch/test_medeha_adhoc.cc.5.o
[1433/1754] cxx: src/medeha/model/EID_home_server_application.cc -> build/src/medeha/model/EID_home_server_application.cc.1.o
[1436/1754] cxx: src/medeha/helper/EID_echo_helper.cc -> build/src/medeha/helper/EID_echo_helper.cc.1.o

In file included from ./ns3/EID_home_server_application.h:30:0,
                 from ./ns3/medeha-module.h:20,
                 from ../scratch/test_medeha_adhoc.cc:21:
./ns3/Buffer_Class.h:33:2: error: conflicting declaration ‘typedef struct ns3::BufferedFrames ns3::BufferedFrames’
 }BufferedFrames;
  ^
In file included from ./ns3/medeha-module.h:10:0,
                 from ../scratch/test_medeha_adhoc.cc:21:
./ns3/Buffer_Class.h:33:2: error: ‘ns3::BufferedFrames’ has a previous declaration as ‘typedef struct ns3::BufferedFrames ns3::BufferedFrames’
 }BufferedFrames;
  ^
In file included from ./ns3/EID_home_server_application.h:30:0,
                 from ./ns3/medeha-module.h:20,
                 from ../scratch/test_medeha_adhoc.cc:21:
./ns3/Buffer_Class.h:36:7: error: redefinition of ‘class ns3::Buffer_Class’
 class Buffer_Class
       ^
In file included from ./ns3/medeha-module.h:10:0,
                 from ../scratch/test_medeha_adhoc.cc:21:
./ns3/Buffer_Class.h:36:7: error: previous definition of ‘class ns3::Buffer_Class’
 class Buffer_Class
       ^
In file included from ./ns3/EID_home_server_application.h:30:0,
                 from ./ns3/medeha-module.h:20,
                 from ../scratch/IS-Based.cc:27:
./ns3/Buffer_Class.h:33:2: error: conflicting declaration ‘typedef struct ns3::BufferedFrames ns3::BufferedFrames’
 }BufferedFrames;
  ^
In file included from ./ns3/medeha-module.h:10:0,
                 from ../scratch/IS-Based.cc:27:
./ns3/Buffer_Class.h:33:2: error: ‘ns3::BufferedFrames’ has a previous declaration as ‘typedef struct ns3::BufferedFrames ns3::BufferedFrames’
 }BufferedFrames;
  ^
In file included from ./ns3/EID_home_server_application.h:30:0,
                 from ./ns3/medeha-module.h:20,
                 from ../scratch/IS-Based.cc:27:
./ns3/Buffer_Class.h:36:7: error: redefinition of ‘class ns3::Buffer_Class’
 class Buffer_Class
       ^
In file included from ./ns3/medeha-module.h:10:0,
                 from ../scratch/IS-Based.cc:27:
./ns3/Buffer_Class.h:36:7: error: previous definition of ‘class ns3::Buffer_Class’
 class Buffer_Class
       ^
Waf: Leaving directory `/home/adnan/porting/ns-allinone-3.19/ns-3.19/build'
Build failed



--
Regards,
ADNAN RASHID


Konstantinos

unread,
Jun 6, 2014, 4:31:10 PM6/6/14
to ns-3-...@googlegroups.com
Hi Adnan,

You have used the typedef twice in two different classes for ns3::BufferedFrames.
I had similar errors and the solution was to properly configure namespaces. see the discussion here  https://groups.google.com/forum/#!msg/ns-3-users/d9e11tyA1x0/VfbGA2eMf24J

K' Dash

unread,
Jun 6, 2014, 4:40:41 PM6/6/14
to ns-3-...@googlegroups.com
dear Kat
hope you are fine and thanx for reply.

as you know i ported my module from ns3.5 into ns3.19, when i include the module it gives error
but when i include only related files in my topology it don't give errors

//#include "ns3/EID_client_helper.h"
//#include "ns3/EID_server_helper.h"
#include "ns3/medeha-module.h"

in this case it gives error

but if i write
#include "ns3/EID_client_helper.h"
#include "ns3/EID_server_helper.h"
//#include "ns3/medeha-module.h"

it does not give me any error

Konstantinos

unread,
Jun 6, 2014, 5:12:44 PM6/6/14
to ns-3-...@googlegroups.com
When you include the module, you include all the files defined in its wscript file.
Probably some other file in that module have also defined this "BufferedFramed".

The other issue might be that your header files do not have "IFNDEF" at the beginning and each time you use them they re-define the classes

K' Dash

unread,
Jun 6, 2014, 5:48:49 PM6/6/14
to ns-3-...@googlegroups.com
1. Your first point is already checked. I wrote both files in modules wscript file. (.h and .cc).
there is an other wscript file in src folder. I think there is no need to provide info of new module. right?

2. I used the grep command to find BufferedFrames in src folder. but unable to find match. see attachments

3.  in my topology code there is no "ifndef". suppose if it exists in medeha-module then how can I check? I mean compiler gives me different error. it is not telling me the particulate file in which "ifndef" makes error.

again  when I include
#include "ns3/medeha-module.h"
it gives me the above errors.

but when I include

#include "ns3/EID_client_helper.h"
#include "ns3/EID_server_helper.h"
//#include "ns3/medeha-module.h"

it gives me no such error. both EID_client_helper.h and EID_server_helper.h"  are part of this medeha-module.





--
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/WCOswlmqjFg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.



--
Regards,
ADNAN RASHID


Screenshot from 2014-06-07 02:25:40.png
Screenshot from 2014-06-07 02:26:21.png
Screenshot from 2014-06-07 02:26:25.png

Konstantinos

unread,
Jun 7, 2014, 6:17:23 AM6/7/14
to ns-3-...@googlegroups.com


On Friday, June 6, 2014 10:48:49 PM UTC+1, K' Dash wrote:
1. Your first point is already checked. I wrote both files in modules wscript file. (.h and .cc).
there is an other wscript file in src folder. I think there is no need to provide info of new module. right?


I do not understand what you mean here. What I was saying is that the madeha-module does not have only the EID_client/server and when you do include the module, you include everything inside it which might cause the problem. 

 
2. I used the grep command to find BufferedFrames in src folder. but unable to find match. see attachments


I spotted a potential problem, could not be the one causing your errors. In the third figure you have:

typedef std::list<BufferedFrames> BufferedFramesList; in the Buffer_Class.h

typedef std::list<BufferedFramesSt> BufferedFramesList; in the modeha-ap-buffer.h

So the same typedef variable (BufferedFramesList) is defined in two different ways. This could cause errors unless properly managed (e.g. namespaces)
 

3.  in my topology code there is no "ifndef". suppose if it exists in medeha-module then how can I check? I mean compiler gives me different error. it is not telling me the particulate file in which "ifndef" makes error.


the #IFNDEF should be added header file, in order to prevent dual declarations.
In NS-3 I trust that every header file has it, but I am not sure that the header files in medeha module have it.
 
For example in EID_client_helper.h you should start with this:

#IFNDEF EID_CLIENT_HELPER_H
#DEFINE EID_CLIENT_HELPER_H

and you end with this

#ENDIF

See for example the header file for the bulksend helper here http://www.nsnam.org/doxygen/bulk-send-helper_8h_source.html
This should be checked for ALL header files in that module not only the helper classes I just gave the example.
 
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.

To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.



--
Regards,
ADNAN RASHID


Reply all
Reply to author
Forward
0 new messages