error C2371: 'LineCollection' : redefinition; different basic types

Discussion in 'C++' started by Samant.Trupti@gmail.com, Aug 4, 2008.

  1. Guest

    Hi,

    I am getting this error.
    error C2371: 'LineCollection' : redefinition; different basic types

    I have 'LineCollection' defined in two header files in one project
    Like
    "typedef std::vector<line> LineCollection;"

    But both of the header file not dependant on each other, they are
    separate.
    Why I am still getting that error?

    How should I solve this problem? Should I just change the name?
    Thanks
    Trupti
     
    , Aug 4, 2008
    #1
    1. Advertising

  2. mlimber Guest

    Re: error C2371: 'LineCollection' : redefinition; different basictypes

    On Aug 4, 1:32 pm, "" <>
    wrote:
    > I am getting this error.
    >   error C2371: 'LineCollection' : redefinition; different basic types
    >
    > I have 'LineCollection' defined in two header files in one project
    > Like
    > "typedef std::vector<line> LineCollection;"
    >
    > But both of the header file not dependant on each other, they are
    > separate.
    > Why I am still getting that error?
    >
    > How should I solve this problem? Should I just change the name?


    No idea. See this FAQ on asking questions about code that doesn't
    work:

    http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.8

    In brief, boil it down to a minimal but complete sample that
    demonstrates the problem, then post it here.

    Cheers! --M
     
    mlimber, Aug 4, 2008
    #2
    1. Advertising

  3. Guest

    Re: error C2371: 'LineCollection' : redefinition; different basictypes

    Ok I will try to write minimal code.
    I have a project called "FileUtil"
    It has two header files and 2 cpp files called
    1. FileCompare.h and FileCompare.cpp
    2. Compare.h and Compare.cpp

    FileCompare.h
    //Some Includes "Doesnot inclide compare.h"
    typedef std::vector<line> LineCollection;
    typedef LineCollection::iterator LineCollectionIter;

    class FileCompare
    {
    ....
    LineCollection compFileMap;
    LineCollection baseFileMap;
    ....
    };

    Compare.h
    //Some Includes "Doesnot inclide FileCompare.h"
    typedef std::vector<line> LineCollection;
    typedef LineCollection::iterator LineCollectionIter;

    class Compare
    {
    ....
    LineCollection m_baseLines;
    LineCollection m_compLines;
    ....
    };

    Now I am getting error C2371: 'LineCollection' : redefinition;
    different basic types.
    I know that they are defined twice. I don't know why since two header
    files are independant on each other.
    Please let me know if this is enough to expalin the problem?
    Thanks
    Trupti
     
    , Aug 4, 2008
    #3
  4. red floyd Guest

    Re: error C2371: 'LineCollection' : redefinition; different basictypes

    On Aug 4, 11:18 am, ""
    <> wrote:
    > Ok I will try to write minimal code.
    > I have a project called "FileUtil"
    > It has two header files and 2 cpp files called
    > 1. FileCompare.h and FileCompare.cpp
    > 2. Compare.h and Compare.cpp
    >
    > FileCompare.h
    > //Some Includes "Doesnot inclide compare.h"
    > typedef std::vector<line> LineCollection;
    > typedef LineCollection::iterator LineCollectionIter;
    >
    > class FileCompare
    > {
    > ...
    >         LineCollection compFileMap;
    >         LineCollection baseFileMap;
    > ...
    >
    > };
    >
    > Compare.h
    > //Some Includes "Doesnot inclide FileCompare.h"
    > typedef std::vector<line> LineCollection;
    > typedef LineCollection::iterator LineCollectionIter;
    >
    > class Compare
    > {
    > ...
    >         LineCollection m_baseLines;
    >         LineCollection m_compLines;
    > ...
    >
    > };
    >
    > Now I am getting error C2371: 'LineCollection' : redefinition;
    > different basic types.
    > I know that they are defined twice.  I don't know why since two header
    > files are independant on each other.
    > Please let me know if this is enough to expalin the problem?



    No. You *still* haven't followed the 5.8 recommentations. Post the
    minimum *COMPILEABLE* code that exhibits the behavior in question.
     
    red floyd, Aug 4, 2008
    #4
  5. James Kanze Guest

    Re: error C2371: 'LineCollection' : redefinition; different basictypes

    On Aug 4, 8:18 pm, "" <>
    wrote:
    > Ok I will try to write minimal code.
    > I have a project called "FileUtil"
    > It has two header files and 2 cpp files called
    > 1. FileCompare.h and FileCompare.cpp
    > 2. Compare.h and Compare.cpp


    > FileCompare.h
    > //Some Includes "Doesnot inclide compare.h"
    > typedef std::vector<line> LineCollection;
    > typedef LineCollection::iterator LineCollectionIter;


    > class FileCompare
    > {
    > ...
    > LineCollection compFileMap;
    > LineCollection baseFileMap;
    > ...
    > };


    > Compare.h
    > //Some Includes "Doesnot inclide FileCompare.h"
    > typedef std::vector<line> LineCollection;
    > typedef LineCollection::iterator LineCollectionIter;


    > class Compare
    > {
    > ...
    > LineCollection m_baseLines;
    > LineCollection m_compLines;
    > ...
    > };


    > Now I am getting error C2371: 'LineCollection' : redefinition;
    > different basic types.
    > I know that they are defined twice. I don't know why since two header
    > files are independant on each other.


    1. As others have pointed out: you haven't posted enough for us
    to reproduce the problem, so anything we say is just a
    guess.

    2. What is "line"? You're allowed multiple typedef's, even in
    the same translation unit, as long as they resolve to the
    same thing. Your error message strongly suggests that you
    have different definitions of "line", which will lead to no
    end of problems.

    3. FileCompare.h may not include Compare.h, and vice versa, but
    logically, you have to expect some client code to include
    both of them. In which case, if "line" is defined
    differently in the two headers, you'll get a problem at
    compile time. (Otherwise, the problems won't appear until
    link time, or possibly even runtime.)

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, Aug 5, 2008
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gernot Frisch

    redefinition, different types

    Gernot Frisch, Sep 13, 2004, in forum: C++
    Replies:
    13
    Views:
    2,242
    Jerry Coffin
    Sep 14, 2004
  2. junaidnaseer
    Replies:
    4
    Views:
    783
    junaidnaseer
    May 9, 2006
  3. merrittr
    Replies:
    0
    Views:
    1,634
    merrittr
    Oct 9, 2009
  4. omnia neo

    error C2375 - redefinition; different linkage

    omnia neo, Apr 23, 2010, in forum: C Programming
    Replies:
    6
    Views:
    3,141
    ImpalerCore
    Apr 23, 2010
  5. omnia neo
    Replies:
    3
    Views:
    1,352
    Alf P. Steinbach
    Apr 24, 2010
Loading...

Share This Page