Platform specifik, exclude serial code when building for ATTiny?

Is is possible like in C# to exclude specific content of my code when building for ATtiny.

I often debug via a bool where throughout my projects i have small "if(debug == true); Serial.println(debuginfo);

but when i build for attiny i have to remove all these, because the Serial command is not used, and i don't really want to add the library due to limited memory.

Was thinking something along the way Unity does it..

#if Arduino
   if(debug == true);
   Serial.println(debuginfo);
#endif

Meaning that piece will ONLY be included/compiled if compiling for a Arduino unit.

etc..

IMHO it would be much simpler to have a sketch for each version specific code.

When you select the board you want to upload to from the list, it defines that board so it will know which io files to link to. You can use that define if you don't mind looking through the source libraries to find out what it is. If you look at Arduino.h you can see a lot of them. I don't know where to get any exhaustive list.

For example, from Arduino.h

#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
#define DEFAULT 0
#define EXTERNAL 1
#define INTERNAL 2
#else  
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__)
#define INTERNAL1V1 2
#define INTERNAL2V56 3
#else
#define INTERNAL 3
#endif
#define DEFAULT 1
#define EXTERNAL 0
#endif

Vaupell:
but when i build for attiny i have to remove all these, because the Serial command is not used,
and i don’t really want to add the library due to limited memory.

Use a different core; one that includes Serial. Continue using if-statements to eliminate the call/code.