Questions tagged [c-preprocessor]
the macro preprocessor for the C and C++ computer programming languages.
16 questions
3
votes
2
answers
2k
views
is #ifdef __SD_H__ considered a bad practice?
Say I'm working on a library^1 to which I want to add support for SD.h^2 but knowing for a fact that many microcotrollers don't support SD.h (therefore they result in compilation errors [eg. Attiny85])...
0
votes
1
answer
171
views
#define from main (.ino) not considered by comiler in own libaries
I have got the problem, that my #define from main (.ino) is not considered by the comiler in my own libaries. This #define MQTT_MODULE is only considered in the main (.ino) programm, but not in ...
1
vote
0
answers
54
views
How initialise and uninitialise serial based on the user's input?
In Summary. If the argument is true, I want to create a function that prints the necessary stuff into the serial. However, if its false serial is uninitialised and does not print anything, it only ...
0
votes
1
answer
99
views
A strange bug in my Arduino ALU
I have discovered a strange error in my Arduino. It's not in the code. I think it's a hardware bug in the ALU of the microcontroller, maybe in clone only.
So there is a variable called feedLimit and ...
1
vote
1
answer
303
views
#define above static const int?
I see a lot of people, but also libraries, defining constants (like pin numbers, length of items etc) as #define:
#define LENGTH 5
While it is recommended to use in this case static const int:
...
0
votes
1
answer
144
views
Segmentation fault and huge SRAM need for Serial.println
I have written my own 'assert' since I want to use it for both Windows and Arduino. The class is called from many files (about 10).
AssertUtils.h:
#pragma once
#define assert(expr) AssertUtils::...
6
votes
2
answers
2k
views
Detect if Serial1 and Serial2 are defined, at compile time
I have my library that uses Serial, Serial1 and Serial2 to establish various logging scenarios. Library user would define the config at class constructor, using simple byte constants like 0, 1 and 2.
...
23
votes
4
answers
19k
views
List of Arduino board preprocessor #defines
When one selects a board within Arduino IDE, a preprocessor definition is added to one of the behind-the-scenes files.
After a lot of hunting and some good fortune I found that the format of this ...