rror: conflicting declaration 'typedef struct

Discussion in 'C++' started by K' Dash, Jun 6, 2014.

  1. K' Dash

    K' Dash Guest

    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' Dash, Jun 6, 2014
    #1
    1. Advertisements

  2. On 6/6/2014 3:47 PM, K' Dash wrote:
    > Dear Members
    >
    > I am not getting that how to resolve these errors. please help


    See FAQ (http://www.parashift.com/c++-faq/), especially section 5.

    > [..]
    > Build failed


    V
    --
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Jun 6, 2014
    #2
    1. Advertisements

  3. K' Dash

    K' Dash Guest

    On Saturday, June 7, 2014 1:04:58 AM UTC+5, Paavo Helde wrote:
    > "K' Dash" <> wrote in
    >
    > news::
    >
    >
    >
    > > 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

    >
    >
    >
    > 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?
     
    K' Dash, Jun 6, 2014
    #3
  4. On 6/6/2014 4:20 PM, K' Dash wrote:
    > On Saturday, June 7, 2014 1:04:58 AM UTC+5, Paavo Helde wrote:
    >> "K' Dash" <> wrote in
    >>
    >> news::
    >>> 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
    --
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Jun 6, 2014
    #4
  5. K' Dash

    Guest

    On Friday, June 6, 2014 3:20:22 PM UTC-5, K' Dash wrote:

    > 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
     
    , Jun 6, 2014
    #5
  6. K' Dash

    K' Dash Guest

    On Saturday, June 7, 2014 2:01:21 AM UTC+5, Paavo Helde wrote:
    > "K' Dash" <> wrote in
    >
    > news::
    >
    >
    >
    > > I follow your suggestion but still same error. please tell me which

    >
    > > file you need to see?

    >
    > >

    >
    >
    >
    > 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' Dash, Jun 6, 2014
    #6
  7. K' Dash

    K' Dash Guest

    On Saturday, June 7, 2014 2:55:18 AM UTC+5, Paavo Helde wrote:
    > "K' Dash" <> wrote in
    >
    > news::
    >
    >
    >
    > > in the NS3 software. so its difficult to send you here. please send me

    >
    > > your email ID.

    >
    >
    >
    > 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.

    :(






    On Saturday, June 7, 2014 2:55:18 AM UTC+5, Paavo Helde wrote:
    > "K' Dash" <> wrote in
    >
    > news::
    >
    >
    >
    > > in the NS3 software. so its difficult to send you here. please send me

    >
    > > your email ID.

    >
    >
    >
    > 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




    On Saturday, June 7, 2014 2:55:18 AM UTC+5, Paavo Helde wrote:
    > "K' Dash" <> wrote in
    >
    > news::
    >
    >
    >
    > > in the NS3 software. so its difficult to send you here. please send me

    >
    > > your email ID.

    >
    >
    >
    > 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
     
    K' Dash, Jun 6, 2014
    #7
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. DanielEKFA
    Replies:
    8
    Views:
    953
    DanielEKFA
    May 16, 2005
  2. Lathe_Biosas
    Replies:
    8
    Views:
    1,235
    Joe Wright
    Sep 2, 2005
  3. Steven T. Hatton
    Replies:
    2
    Views:
    963
  4. Mohammad Omer Nasir
    Replies:
    8
    Views:
    4,733
    Dave Rahardja
    Feb 19, 2007
  5. Ehud Shapira
    Replies:
    20
    Views:
    1,777
    Ehud Shapira
    Jun 30, 2007
  6. slocum
    Replies:
    3
    Views:
    699
    slocum
    Apr 11, 2008
  7. eliben

    forward declaration of a struct typedef

    eliben, Jan 9, 2009, in forum: C Programming
    Replies:
    6
    Views:
    3,555
    eliben
    Jan 10, 2009
  8. Skybuck Flying
    Replies:
    5
    Views:
    1,757
    ImpalerCore
    Nov 29, 2011
Loading...