Conditional compilation fails

Perhaps you now feel able to comment on the operation of the IDE, Version 1.0.1, by the way.

Sure. The IDE modifies your sketch. It adds some include statements, function prototypes, and a main() function.

The key is where it does this.

Add a statement to the top of your first sketch:

int dummy;

Compile, and you'll get no errors.

Now, make the change to produce the second sketch, with the dummy variable stiff defined. No errors this time, either.

So, there clearly is not a bug in the compiler. The bug is in where the IDE inserts it's stuff. If you enable verbose output in the IDE, you can see the file that the IDE has modified:

#undef USECONST
#ifdef USECONST
#include "Arduino.h"
int freeRam();
unsigned long sketchSize(void);
void setup();
void loop();
const TYPE KEYA =  1;   
#else
#define KEYA ((TYPE) 1)   
#endif
boolean v;

You can see that the IDE added stuff in the middle of the conditional block, just before the variable declaration statement. Since that block of code will not be seen by the compiler, stripped out by the preprocessor, the include file is not included.

By putting the int dummy; statement at the top, you change where the IDE adds stuff:

#include "Arduino.h"
int freeRam();
unsigned long sketchSize(void);
void setup();
void loop();
int dummy;

Now, clearly the added stuff is unconditionally added, so there is no problem with compilation.