[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A question to everyone...



Steve Baker <sjbaker1@airmail.net> writes:

> If you use MSVC under Windoze, there are a few nasty compiler
> differences that bite you - but nothing that an hour's work won't
> fix. The worst (if you are writing C++) is:
> 
>    for ( int i = 0 ; i < 10 ; i++ )
>    { whatever }
>    for ( int i = 0 ; i < 20 ; i++ )
>    { whatever_else }
> 
> ..will get you a 'multiple definition of i' error under MSVC,
> but the alternative:

There is an simple workaround for this, with single good old #define
you can get standard C++ behaviour under MSVC for the for-loop:

#ifdef WIN32
#define for if(0);else for
#endif /* WIN32 */

-- 
ICQ: 59461927                                    http://pingus.seul.org | 
Ingo Ruhnke <grumbel@gmx.de>           http://pingus.seul.org/~grumbel/ |
------------------------------------------------------------------------'