Tuesday, January 15, 2008

Silly Microsoft

So, I just wasted maybe 10 minutes of my life fixing a lame problem in some experimental code of mine. I basically wrote up really quickly a simple function I needed. It looked more or less like:

int f( int a, int b )
int big;
int small;

... then some junk here ...

Anyway, I was getting a funky compilation error from MSVC 6 (ya, I'm old school).

error C2632: 'int' followed by 'char' is illegal

I then spent some time trying to find out what was going wrong... I assumed I had mangled up some code above this silly little function. After some searching I was still a bit confused, and then it struck me that maybe Microsoft somehow #defined my simple variable name to something.

Sure enough, inside RPCNDR.h, we have:

* Other MIDL base types / predefined types:

#define small char

Anyway, it wasn't a ton of time wasted or anything, but I just felt like bitching about this silliness. So, the lesson here is don't name your local variable small if RPCNDR.h is included in your project (most likely by including Windows.h).

1 comment:

Ryan Wong said...

Why don't you forward this to Raymond Chen (and continue to bug him daily until he agrees to post a blog about this)

At least there should be a way to undef these silly things inside your CPP files as long as they don't depend on RPC.