tags:

views:

60

answers:

3

I am converting an MFC application for deadlock detection in to Simple console application. During this process I found many errors saying like

error C2365: 'CmdLockMutex' : redefinition; previous definition was 'enumerator'

I am unable to remove this error. Kindly if someone could help me in this regard.

+1  A: 

Sounds like you need a header guard around your definition of CmdLockMutex (Add #pragma once at the top of its .h file.). Or rather you have a naming conflict.

Maybe you have something like this:

enum MyEnum { MyEnumVal1, MyEnumVal2 };

//....

class MyEnum
{

};
Brian R. Bondy
A: 

The obvious answer is that you have prevously used the name CmdLockMutex - probably in an enum. Search your code for all occurnces of "CmdLockMutex"

LeonixSolutions
+1  A: 

I've had an issue like this where some code definitions were placed in a header file. The header was included in two places, and so conflicted with itself. My solution was to move them to their own cpp file. You might be seeing something like this.

Another cause can be failing to use a #pragma once or wrap with the #ifndef technique in a header.

Tim Rupe
In the first case if include guards were present you'd have got a linker error not a compiler error; the header does not strictly conflict with itself in that case, but rather you get conflicting definitions in separate compilation units. So since this is a compiler error, by bet is on the second (no include guards). All good points though.
Clifford
@Clifford - I agree. For me, the first part was a linker conflict.
Tim Rupe