473,473 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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<lineLineCollection;"

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 '08 #1
7 4218
Sam an********@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<lineLineCollection;"

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
Aug 4 '08 #2
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<lineLineCollection;"

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-lit...t.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
Aug 4 '08 #3
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<lineLineCollection;
typedef LineCollection::iterator LineCollectionIter;

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

Compare.h
//Some Includes "Doesnot inclide FileCompare.h"
typedef std::vector<lineLineCollection;
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 '08 #4
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<lineLineCollection;
typedef LineCollection::iterator LineCollectionIter;

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

};

Compare.h
//Some Includes "Doesnot inclide FileCompare.h"
typedef std::vector<lineLineCollection;
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.

Aug 4 '08 #5
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
Aug 4 '08 #6
In article
<45**********************************@j22g2000hsf. googlegroups.com>,
red floyd <re******@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)
Aug 4 '08 #7
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<lineLineCollection;
typedef LineCollection::iterator LineCollectionIter;
class FileCompare
{
...
LineCollection compFileMap;
LineCollection baseFileMap;
...
};
Compare.h
//Some Includes "Doesnot inclide FileCompare.h"
typedef std::vector<lineLineCollection;
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:ja*********@gmail.com
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
Aug 5 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Simon | last post by:
Hi, I'm having a problem with templates and specialisation. I'm using it to overload the same function so it can return different things. I can't see what I'm doing wrong, although my compiler...
4
by: junaidnaseer | last post by:
Hi ! I am facing a problem that I have defined a function which when called in the same file generates an error as follows; " visual c error C2371 redefinition basic types see...
9
by: Prasad | last post by:
HI, I am a beginner in VC++.. I am trying to write a Win32 console application in visual studio.. I am using following header files.. #include <STRING> using namespace std; #include...
6
by: Pierre Couderc | last post by:
What do I do wrong? class CTest { public: CTest(int uu); }; void ttt() {
6
by: pasalic.zaharije | last post by:
I write some project, and after few lines (ok, not few, after a lot of lines) i got internal compiler error. After few hours of looking trough my code, I find error: two same names in typedef and...
2
by: Mohammad Omer | last post by:
Hi, i am developing an application which uses WAB API's, for doing all this i am using vs2k5. I have wab.h header file included in my project to use WAB api's but after compilation one error...
1
by: Angus | last post by:
Why moving a function from protected to public area in class causes error C2556 - overloaded function differs only by return type I have a protected function called GetState like this: enum...
2
by: im2cre8iv | last post by:
Here is my code where I am receiving the error: #include <fstream> #include "BinaryTree.h" using namespace std; Node* BinaryTree::MakeTree(ifstream& infile) { char name; infile>>name;
11
by: Tim H | last post by:
The following program compiles just fine in C, but not in C++. Can anyone explain why? I have a chunk of code that defines stuff like this in headers (without the extern) that I can not easily...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.