test.ino:
#define __TESTING
#include <test.h>
void setup() {
Serial.begin(9600);
test();
#ifdef __TESTING
test1();
#else
test2();
#endif
}
void loop() {}
test.h:
#ifndef test_h
#define test_h
#include "Arduino.h"
void test();
#ifdef __TESTING
#warning __TESTING defined in test.h
void test1();
#else
#warning __TESTING UNdefined in test.h
void test2();
#endif
#endif
test.cpp:
#include "Arduino.h"
#include "test.h"
#ifdef __TESTING
#warning __TESTING defined in test.cpp
#else
#warning __TESTING UNdefined in test.cpp
#endif
#ifdef __TESTING
void test(){
Serial.println("test 1");
}
void test1(){
Serial.println("test 1::test1()");
}
#else
void test(){
Serial.println("test 2");
}
void test2(){
Serial.println("test 2::test2()");
}
#endif
When __TESTING is defined
#define __TESTING
I see the following verbose output:
warning: #warning __TESTING defined in test.h
warning: #warning __TESTING UNdefined in test.h
warning: #warning __TESTING UNdefined in test.cpp
If __TESTING is undefined,
//#define __TESTING
I see the following verbose output:
warning: #warning __TESTING UNdefined in test.h