Complier woes changing float to long

I have a large sketch, working, with many floating-point operations in nested loops. To speed things up, I'm bit-by-bit changing things over to long calculations where possible, and hit a snag. When I changed one function from float whatever() to long whatever(), this generated an error which I only removed by (I think, I tried quite a bit) copying the whole sketch into a new one; subsequent investigation refined the problem down to something demonstrable in the bare minimum sketch, as below:

#if 0  //compile first with 0, then change to 1 to show problem
long test()
{
}
#else
float test()
{
}
#endif

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly: 
}

Compiling the above with the #if 0 is OK (actually, for me it gives undefined reference to `setup', 'loop', but that's something else...), but then changing to #if 1 (to use the long version of test()) and compiling gives

float_long:5: error: new declaration 'float test()'
float_long:4: error: ambiguates old declaration 'long int test()'

It's possible to get rid of the error just by changing one of the Test function names, but this is unpalatable when the function is used multiple times buried in expressions as each use needs wrapping in something like #ifdef USE_LONG_TEST/#else/#endif to switch the used functions easily to compare float and long performance. It appears the compiler is remembering some stuff from one run to another (like precompiled headers), is there anything simple I can do to force a full recompile, or otherwise fix this easily next time it happens?

This is on v1.0.3

It's possible to get rid of the error just by changing one of the Test function names, but this is unpalatable when the function is used multiple times buried in expressions as each use needs wrapping in something like #ifdef USE_LONG_TEST/#else/#endif to switch the used functions easily to compare float and long performance. It appears the compiler is remembering some stuff from one run to another (like precompiled headers), is there anything simple I can do to force a full recompile, or otherwise fix this easily next time it happens?

You should enable verbose mode when compiling. Then, you should hunt down the cpp file that is created from your sketch to see what the IDE is doing to convert the .ino file that the compiler wouldn't understand to a .cpp file that it does understand.

The IDE adds code to your sketch. WHERE it adds it is the problem. Code is added just before the first executable statement in the code. The problem is that the IDE can't determine that the preprocessor will first strip out some code, so it gets the insertion point wrong when the first executable statement is in a preprocessor block.

Add:

byte dummy;

as the first line of code in your sketch, to give the IDE a hint where to insert code.

Put your code with the #if stuff into another file (any .cpp in the same directory). The main sketch is transformed into a .cpp file by the IDE which then looks about this:

#line 1 "sketch_may08a.ino"

#include "Arduino.h"
void setup();
void loop();
long mytest();
float mytest();
#line 2
void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly: 
}

#ifdef TESTING
long mytest()
{
}
#else
float mytest()
{
}
#endif

As you can see the IDE is providing the prototypes and don't care for the precompiler directives. It doesn't do that for the other files, just for the main sketch (*.ino).