Compiler problem? [SOLVED]

I've run into a weird problem with (I presume) the compiler and managed to reduce it to a few small test cases. I have tested them on V.0023 and V1.0 and they all work/fail the same way - I have a Duemilanove 328.
I'll start with the code from the description of setup() at setup() - Arduino Reference
This compiles (as it should):

int buttonPin = 3;
void setup()
{
  Serial.begin(9600);
  pinMode(buttonPin, INPUT);
}
void loop()
{
  // ...
}

Now let's suppose that the use of the buttonPin is optional and modify it so that it can be removed with ifdef - this also compiles:

#define NO_BUTTON
#ifdef NO_BUTTON
int buttonPin = 3;
#endif
void setup()
{
  Serial.begin(9600);
#ifdef NO_BUTTON
  pinMode(buttonPin, INPUT);
#endif
}
void loop()
{
  // ...
}

BUT if I decide I don't want the button, commenting the define out like this:

//#define NO_BUTTON
#ifdef NO_BUTTON
int buttonPin = 3;
#endif
void setup()
{
  Serial.begin(9600);
#ifdef NO_BUTTON
  pinMode(buttonPin, INPUT);
#endif
}
void loop()
{
  // ...
}

gives the compiler error message:

test23.cpp: In function 'void setup()':
test23:6: error: 'Serial' was not declared in this scope

Why?

Pete
P.S. I searched for this message and couldn't find any solution.

It has to do with how the IDE adds include statements to the .cpp file that it creates from your sketch. Include files are added, if I remember correctly, before the first executable statement in the code. So, they get added in the middle of your #ifdef block. When that block is not active, neither are any of the include files. You need to add some dummy code before the commented out #define statement so the IDE can find the right insertion point for the include files.

When I add "char dummy;" in front of the define all is well!
Thanks very much Paul.
Pete