Game Development Community

Regarding the file typesWin32.h

by Jane Austen · in Torque Game Engine · 03/05/2002 (2:36 am) · 2 replies

Why does there exists the following define for VC?

#ifdef _MSC_VER
#define for if(false) {} else for
#endif

#1
03/05/2002 (4:14 am)
Hi,

for(int i=0; i<3; i++)
// do something

for(int i=0; i<5; i++)
// do something

If you declare the same variable in two different for-statements, you get the following error in Visual C++:

error C2374: 'i' : redefinition; multiple initialization


This is not standard C++ behaviour. You can change this behaviour with the /Za compiling option, or you redefine the for keyword.

Bye
Alex
#2
03/05/2002 (5:37 am)
Oh ya, I got it.

Thank you very much!