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. See FAQ (http://www.parashift.com/c++-faq/), especially section 5.
    V
     
    Victor Bazarov, Jun 6, 2014
    #2
    1. Advertisements

  3. K' Dash

    K' Dash Guest

    I follow your suggestion but still same error. please tell me which file you need to see?
     
    K' Dash, Jun 6, 2014
    #3
  4. _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
     
    Victor Bazarov, Jun 6, 2014
    #4
  5. K' Dash

    Guest


    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



    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



    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.

    :(






     
    K' Dash, Jun 6, 2014
    #7
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.