#ifdef does not work at all on Due

Hello

on actual ide compiled for Arduino Due:

i tried to exclude some code with (e.g.)

#ifdef RUN_STORE_SAMPLES

or

#if defined RUN_STORE_SAMPLES

in the ino-File, with lots of includes

but regardless what i use

if i define RUN_STORE_SAMPLES or i comment the definition out
or i delete the definition off the file
the section between #ifdef and #endif is always been included in the file
the #ifdef or the #if or the #endif are recognized by the editor and turned green.

No duplicates of the name are possible, other Names doesnt work also as it seems.

Any ideas?

thanks in advance

Post the code. All of it. You've made some mistake and it is impossible to tell exactly what without seeing it.

if i not define the variable the lower part should never been included.
What could possibly go wrong?

#if !defined RUN_STORE_SAMPLES
Serial.println("NO SD-Card output");
#endif

#ifdef RUN_STORE_SAMPLES
//unsigned short ext = DueFlashStorage.read(EEPROM_ADRESS);
//DueFlashStorage.update(EEPROM_ADRESS, ext);

Serial.println("Checking SDCard");
int err = 0;
int ext = 0;
String filename = "";
String head = "sample" ;

// determine free filename
do{
filename = head + ++ext + ".txt";
err = fileobject.open_new_file(filename);
} while (err == ERR_FILE_FILE_EXISTS);

if (err != OK) {
Serial.println("###############Error is SD Card in? ###################");
Serial.println("Stopping");
while(1);
};

Serial.print("Filename for new samplefile:");
Serial.println(filename);
#endif

#if !defined

Is that good syntax?

I always used ifndef

A basic example :

//#define NO_BLINK
void setup() {

pinMode(LED_BUILTIN, OUTPUT);

}


void loop() {

#ifndef NO_BLINK
PIOB->PIO_ODSR ^= PIO_ODSR_P27;
#endif
delay(1000);
}

I had #ifndef tested at first,
I had checked all variations.

i develop some parts of the code with Visual Studio and compile them for intel for easier debugging of some decoding logic
and the Arduino IDE for testing the hardware depend parts.
Maybe there is an issue with the encoding of the file, but the .ino should have never been touched by VS which uses another main-program...

I now checked all files for missing #ifdef s or #endif s

no inconsistencies found.

Sorry, My bad.

Found the problem.
Nothing to do with #ifdef

closed

Delta_G:

#if !defined

Is that good syntax?

I always used ifndef

Yes, it's good. I actually prefer this syntax to #ifdef/#ifndef because I feel like it works better with my practice of adding comments to indicate which preprocessor conditionals go with each other:

#if !defined(FOOBAR)
#else // !defined(FOOBAR)
#endif  // !defined(FOOBAR)

vs.

#ifndef FOOBAR
#else // FOOBAR
#endif  // FOOBAR

SIMPLE

#ifndef F_CPU

#define F_CPU 20000000UL

#endif

phunkz:
Sorry, My bad.

Found the problem.
Nothing to do with #ifdef

closed

And that's why we ask for complete code that exhibits the example.

Do you mind sharing what was wrong so other users that are experiencing the same problem might have an idea what to look for.