In my Arduino program, I have a set of different options for setup/loop functions that I'm planning to select using a #define macro. I have the following already:
namespace Part2 {
void setup() {
// ...
}
void loop() {
// ...
}
} // namespace Part2
// ...
// Choose which tutorial video will be built
#define PREFIX Part2
void setup() { PREFIX::setup(); }
void loop() { PREFIX::loop(); }
However, I think this looks quite messy and I'm wondering if there's a way to define setup/loop as an alias to PREFIX::setup/PREFIX::loop instead of using this one-line function call. I've tried most of the methods suggested in these two SO posts (Post 1, Post 2), but both result in variants of the same compiler error:
src/main.cpp:27:15: error: 'void (* setup)()' redeclared as different kind of symbol
I think this is because the Arduino.h header file included in every program has already declared setup/loop and the syntaxes mentioned in the aforementioned SO posts deal with declaring/defining an entirely new function alias (as opposed to defining an already declared function as an alias to another). Is there an easy way to make this work?