rror: conflicting declaration 'typedef struct

K

K' Dash

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
 
K

K' Dash

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

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'


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



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

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

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'


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



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

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

class Buffer_Class

Waf: Leaving directory
`/home/adnan/porting/ns-allinone-3.19/ns-3.19/build' Build failed



It is hard to tell without seeing any sources, but it looks like your

header file lacks include guards. Nowadays just adding



#pragma once



in the top of the header files takes care of this issue for most major

C++ compiler implementations. If this does not solve your problem,

extract and post the relevant source code.



hth

Paavo

I follow your suggestion but still same error. please tell me which file you need to see?
 
V

Victor Bazarov

Dear Members

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

It is hard to tell without seeing any sources, but [...]
If this does not solve your problem,

extract and post the relevant source code. [..] ^^^^^^^^^^^^^^^^^^^^

I follow your suggestion but still same error. please tell me which file you need to see?

_Relevant_ files. You will need to determine which ones are relevant.
We help you without seeing the code. We can't even tell you which files
are relevant and which aren't.

If this is your program, follow the advice of FAQ 5.8. If it's not your
program, *contact the author of the program*.

V
 
C

Chris

I follow your suggestion but still same error. please tell me which file you need to see?


Make the most minimal example you possibly can. Copy your files and then start removing as much as you can while retaining your error. If the error goes away when you remove something, you've found part of the answer. Posting a lot of code will likely get entirely ignored... so it's in your interest to make it easy for people to help you. Also, narrowing your code downto just the error and nothing more may help you discover the answer on your own.


Eventually you'll probably find that you are in fact lacking include guardsas already suggested, or else you actually are defining multiple classes with the same names.

If the #pragma once doesn't work, ensure your .h files have something like:

<TOP OF FILE>
#ifndef someFilename_H_
#define someFilename_H_

.... rest of header

#endif // someFilename_H_
<BOTTOM OF FILE>

Those are the guards to protect against multiple inclusion.

Chris
 
K

K' Dash

The relevant parts of the file or files which I can try to compile and get

the same error. This obviously includes parts of ns3/medeha-module.h, and

possible the top of the files ns3/medeha-module.h and

ns3/EID_home_server_application.h as well.



Cheers

Paavo



Dear Paavo

I am working in Network simulator 3. this medeha-module is added by me in the NS3 software. so its difficult to send you here. please send me your email ID.
 
K

K' Dash

No, sorry, I am not so eager to solve your problems. If you cannot extract

a minimal example of your problem which can be posted here, then you will

have to find help somewhere else I'm afraid. But try also the include

guards suggestion from Chris, maybe you have some old version of gcc.



Cheers

Paavo



its ok Paavo. :)

1. I am updating my gcc and g++.

2.
[adnan@localhost ns-3.19]$ ./waf --run scratch/IS-Based
Waf: Entering directory `/home/adnan/porting/ns-allinone-3.19/ns-3.19/build'
[1610/1752] cxx: scratch/IS-Based.cc -> build/scratch/IS-Based.cc.9.o
In file included from ./ns3/EID_home_server_application.h:30:0,
from ./ns3/medeha-module.h:20,
from ../scratch/IS-Based.cc:28:
../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:28:
../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:28:
../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:28:
../ns3/Buffer_Class.h:36:7: error: previous definition of 'class ns3::Buffer_Class'
class Buffer_Class



see the errors
when i use grep command for last error, it did not show me and any other file in which "class Buffer_Class" writen except Buffer_Class.h file.

:(






No, sorry, I am not so eager to solve your problems. If you cannot extract

a minimal example of your problem which can be posted here, then you will

have to find help somewhere else I'm afraid. But try also the include

guards suggestion from Chris, maybe you have some old version of gcc.



Cheers

Paavo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top