Preprocessor make me mad...

HEllo.

Well, interfacing is maybe not the right place to do..but I start to get made with preprocessor !
I'm using #define, #if def, #endif... buuttt my code is bugging

I paste the code whitch is working (just a sample of the line that seem to bug) :

1st working code :

#define SPI
#ifdef SPI

char spi_transfer(volatile char data)
{
SPDR = data; // Start overførslen
while (!(SPSR & (1<<SPIF))) // Vent til overførslen er fuldført
{
};
return SPDR; // returnere de data der er blevet sendt, hvis de evt skulle bruges
}

byte SPI_write(int value) // Her sker processen med at sende data
{
digitalWrite(SLAVESELECT,LOW); // Gør klar til at sende
spi_transfer(value); // Sender data
digitalWrite(SLAVESELECT,HIGH); // Frigiv slaven
}

#endif

byte mapEcran[24][18];

as you see I defined the SPI constant to compile SPI code when I need.

when replace
#define SPI with //#define SPI,mean I don't want compile using spi code

I receive a message :
error : 'byte' does not name a type In function 'void setup()'

byte x, is the first line of code variable I use in the setup function.

if I remove the line of setup function, I get the error at the 1st function using 'byte ....'

like if the line byte mapEcran... cause trouble when the SPI constant is not set

I really don't see what is wrong...

Any help could help.

Could you post the complete source code, please? It sounds like you may have a misplaced curly bracket somewhere.