views:

34

answers:

1

Hi,

I am working in a migration project from VC++6 to VC++9. I am using Custom Enum in a VC++9 project causes a compilation error as it is duplicating with mfc base class winuser.h.

Sample code:-

enum CHKTYPE{ INPUT, READER, BOTH_IR };    

Error:-

error C2365: 'INPUT' : redefinition; previous definition was 'typedef'.
c:\program files\microsoft sdks\windows\v6.0a\include\winuser.h(5292) : see declaration of 'INPUT'    

This is not a problem with VC++6.

+1  A: 

You used to compile your code with a very old version of the Windows SDK. VC6 is even older than Windows XP, the operating system that added the SendInput() API function.

You could work around your problem with

 #define _WIN32_WINNT 0x400   // Targeting Windows 2000
 #include <windows.h>

But you then cannot use any APIs that were added after Windows 2000. Probably not a real problem considering how old your code is. Move ahead by just renaming INPUT or by putting your class in its own namespace.

Hans Passant
I don't think renaming INPUT would be a good solution. If we need to use typedef or enum for our project, is it good thing we need to check whether mfc classes got the same typedef already or not. Namespace is also not the case here, since I am using enum as type across the project by including .h file.I need some solution to use the custom types which was already defined as mfc types except classes.
Snabak Vinod
Well, I gave you the one-liner solution. There's no additional magic available if you don't want to use the alternatives.
Hans Passant
Could this just be a sign of things to come( i mean if you are to migrate the entire code then it will take some doing). But i think it is better late than never. Isnt there any ready reference which mentions all these things.
ckv
Those things to come happened about 8 years ago. Dig through the MSDN Library "What's New" sections for VS2002, 2003, 2005, 2008 and 2010.
Hans Passant