KurtE
Senior Member+
I am playing around with some MTP stuff and trying to detect if the Sketch is using SD library or not... So __has_include...
But I am getting strange results.... Or at least the feel strange to me... Short version.
Suppose: For lack of anything I have a header file "XYZ.h"
That just has:
Now suppose I have sketch (or library)... That has like:
As expected on the T4.1, it
Prints out that is not defined...
However if you instead do:
It still prints "BUILTIN_SDCARD NOT defined"
I am confused.
However if instead you do:
It works as expected
So what is going on in the second case?
But I am getting strange results.... Or at least the feel strange to me... Short version.
Suppose: For lack of anything I have a header file "XYZ.h"
That just has:
Code:
#ifndef _XYZ_H_
#define MTP_Storage_H
#if defined(__has_include) && __has_include(<SD.h>)
#pragma message " __has_include(<SD.h>"
#include <SD.h>
#endif
#else
#pragma message " NOT __has_include(<SD.h>"
#endif
Now suppose I have sketch (or library)... That has like:
Code:
#include "XYZ.h"
void setup() {
// put your setup code here, to run once:
while(!Serial) ;
Serial.begin(115200);
delay(500);
Serial.println("Test for include file");
#ifdef BUILTIN_SDCARD
Serial.printf("BUILTIN_SDCARD defined %u\n", BUILTIN_SDCARD);
#else
Serial.println("BUILTIN_SDCARD NOT defined");
#endif
}
void loop() {
// put your main code here, to run repeatedly:
}
Prints out that is not defined...
However if you instead do:
Code:
#include "XYZ.h"
#include <SD.h>
void setup() {
// put your setup code here, to run once:
while(!Serial) ;
Serial.begin(115200);
delay(500);
Serial.println("Test for include file");
#ifdef BUILTIN_SDCARD
Serial.printf("BUILTIN_SDCARD defined %u\n", BUILTIN_SDCARD);
#else
Serial.println("BUILTIN_SDCARD NOT defined");
#endif
}
void loop() {
// put your main code here, to run repeatedly:
}
I am confused.
However if instead you do:
Code:
#include <SD.h>
#include "XYZ.h"
void setup() {
// put your setup code here, to run once:
while(!Serial) ;
Serial.begin(115200);
delay(500);
Serial.println("Test for include file");
#ifdef BUILTIN_SDCARD
Serial.printf("BUILTIN_SDCARD defined %u\n", BUILTIN_SDCARD);
#else
Serial.println("BUILTIN_SDCARD NOT defined");
#endif
}
void loop() {
// put your main code here, to run repeatedly:
}
So what is going on in the second case?