Solved

Error C2011 in Visual C++ 6.0 ('struct' type redefinition)

Posted on 2004-04-13
2
17,458 Views
Last Modified: 2012-08-14
Hi-

I'm trying to write a small program that will "ping" in a Windows environemnt using rawping.
When I try to build the project I get the error messages:

c:\ folder\subfolder\project name\rawping.h (line number) : error C2011: 'IPHeader' : 'struct' type redefinition

and

c:\folder\subfolder\project name\rawping.h (line number) : error C2011: 'ICMPHeader' :'struct' type
redfinition

I haven't been able to find much information about  error C2011 . I understand that a structure is the same as a class except that its members are public by default.

I am assuming that  a 'struct' can be defined only once but not sure when / where it is defined.

Both 'IPHeader' and 'ICMPHeader' appear in 3 different files: rawping.cpp, rawping.h and rawping_driver.cpp .

My questions: assuming a 'struct' can be defined only once, when/where should it be defined?
(as the error appears in the header file, I'm guessing the compiler found the 'struct' in one of the .cpp files)

What other references to IPHeader and ICMPHeader need to be removed?

Any help will be appreciated.

Thanks,

Charley
 
0
Comment
Question by:Charley50
  • 2
2 Comments
 
LVL 45

Expert Comment

by:sunnycoder
ID: 10820570
You are right ... struct can be defined only once ... Best option is to define it in a header file and include that header file in all the .c or .cpp files that need it
0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 250 total points
ID: 10820609
Remove all definitions of the structs which give error from c/cpp files and keep them (the struct declarations) in the header files
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
visual studio and gui 6 40
Bartender - Printing Duplicate Records On Label 2 169
maxBlock challenge 30 101
MaxSpan challenge 9 67
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now