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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Samant.Trupti@gmail.com

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

    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<lin eLineCollection ;"

    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
  • Victor Bazarov

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

    Sam ant.Trupti@gmai l.com 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<lin eLineCollection ;"
    >
    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
    A single line of code included in you post inside the double quotes is
    not enough to diagnose the issue.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask

    Comment

    • mlimber

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

      On Aug 4, 1:32 pm, "Samant.Tru...@ gmail.com" <Samant.Tru...@ gmail.com>
      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<lin eLineCollection ;"
      >
      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:



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

      Cheers! --M

      Comment

      • Samant.Trupti@gmail.com

        #4
        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<lin eLineCollection ;
        typedef LineCollection: :iterator LineCollectionI ter;

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

        Compare.h
        //Some Includes "Doesnot inclide FileCompare.h"
        typedef std::vector<lin eLineCollection ;
        typedef LineCollection: :iterator LineCollectionI ter;

        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

        Comment

        • red floyd

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

          On Aug 4, 11:18 am, "Samant.Tru...@ gmail.com"
          <Samant.Tru...@ gmail.comwrote:
          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<lin eLineCollection ;
          typedef LineCollection: :iterator LineCollectionI ter;
          >
          class FileCompare
          {
          ...
                  LineCollection compFileMap;
                  LineCollection baseFileMap;
          ...
          >
          };
          >
          Compare.h
          //Some Includes "Doesnot inclide FileCompare.h"
          typedef std::vector<lin eLineCollection ;
          typedef LineCollection: :iterator LineCollectionI ter;
          >
          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.

          Comment

          • Victor Bazarov

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

            red floyd wrote:
            [..] Post the
            minimum *COMPILEABLE* code that exhibits the behavior in question.
            To the OP:

            IOW, I should be able to copy the text out of your message, paste it
            into my IDE (in my 'test' project) and hit 'compile', without messing
            with file names, splitting it into files (unless that's the main issue)
            or removing any comments or line numbers from your code. Preferably, it
            shouldn't be necessary to splice any lines, so format your code to fit
            into your message without any text wrapping, if possible; but it's no
            big deal if it happens.

            V
            --
            Please remove capital 'A's when replying by e-mail
            I do not respond to top-posted replies, please don't ask

            Comment

            • blargg

              #7
              Re: error C2371: 'LineCollection ' : redefinition; different basic types

              In article
              <451bb513-8343-455b-9395-082f3032d376@j2 2g2000hsf.googl egroups.com>,
              red floyd <redfloyd@gmail .comwrote:
              On Aug 4, 11:18 am, "Samant.Tru...@ gmail.com"
              <Samant.Tru...@ gmail.comwrote:
              [snip non-compilable code]
              >
              No. You *still* haven't followed the 5.8 recommentations . Post the
              minimum *COMPILEABLE* code that exhibits the behavior in question.
              Someone might object that posting a standalone test program is too much
              work, but in making a standalone test program, the problem would likely
              be solved in the process of condensing it down, which is one point of
              this advice. (agreeing with your response here)

              Comment

              • James Kanze

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

                On Aug 4, 8:18 pm, "Samant.Tru...@ gmail.com" <Samant.Tru...@ gmail.com>
                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<lin eLineCollection ;
                typedef LineCollection: :iterator LineCollectionI ter;
                class FileCompare
                {
                ...
                LineCollection compFileMap;
                LineCollection baseFileMap;
                ...
                };
                Compare.h
                //Some Includes "Doesnot inclide FileCompare.h"
                typedef std::vector<lin eLineCollection ;
                typedef LineCollection: :iterator LineCollectionI ter;
                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:james.kan ze@gmail.com
                Conseils en informatique orientée objet/
                Beratung in objektorientier ter Datenverarbeitu ng
                9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

                Comment

                Working...