# 'class' type redefinition



## n00bface (May 25, 2003)

hi i'm having a little problem with a compile error. 


> error C2011: 'AutoMove' : 'class' type redefinition


is this supposed to mean that i already defined class AutoMove somewhere else? any help would be useful thanx


----------



## AlbertB (Nov 24, 2002)

According to my Vis Stud 6 Help, C2011 is telling you that you have defined the identifier "Automove" as a type "Class" elsewhere. It would seem that your guess is pretty accurate.

Quoting Help:

Compiler Error C2011
'identifier' : '_type_' type redefinition

The specified identifier was already defined as type _type_.

The following is an example of this error:

struct S;
union S; // error

I hate it when that sort of thing happens!


----------



## joeAverage (Jan 17, 2006)

Hi, 
There is another cause for this error:

If you have the same include file, ie the class definition file, in two folders which are in your include path you will get this error:

project folder
|
MyClass.h ( In local Folder )
|
|--> Folder on Include Path
|
MyClass.h ( Second copy of file in this folder )

What happens is that the compiler reads the second file without telling you that there is a second file involved.
This means that you keep looking for the error in the wrong place.
The fact the compiler doesn't flag the second file is a serious bug in the compiler in my opinion, as the description of the error is totally innaccurate.
The 'type' is not defined elsewhere, what is actually happening is that the compiler is opening two files with the same name and including them without telling the user, which is plain nuts.

The solution to this particular problem is to do a file search along your inlcude path ( including the local project folder) for the class or file name and locating ( and removing ) the duplicate file.

Hope this helps


----------



## DannySun-NY (Feb 8, 2007)

If the class interface is given in a header file, then there should be a header guard 
#ifndef ABC
#define ABC
...class interface here

#endif

Forgetting to put in a header guard, or having an invalid header guard (e.g., a typo), may generate this error.


----------

