Questions tagged [c-preprocessor]

the macro preprocessor for the C and C++ computer programming languages.

Filter by
Sorted by
Tagged with
24
votes
4answers
4k views

Why use an int variable for a pin when const int, enum or #define makes much more sense

Why do people use a variable to specify a pin number when the pin is unlikely to change throughout the execution of the code? Many times I see an int being used for a pin definition, int led = 13; ...
8
votes
4answers
7k 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 ...
6
votes
2answers
1k 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. ...
2
votes
1answer
79 views

Syntax of binary Constants

I was trying to compile some Arduino code on the PC for testing when I noticed some strange syntax for numerical binary constants. Convetion seems to be to declare them like so: static const ...
2
votes
1answer
35 views

Remove Function at Preprocessor Time

I have a single function for debugging messages, used through all the project. When KEYDEBUG is defined as 1 or 0, the function is enabled or disabled as required. #define KEYDEBUG 0 void debugging(...
1
vote
1answer
63 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: ...
1
vote
1answer
56 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::...
0
votes
0answers
188 views

where is avr\interrupt.h on a Windows installation?

I'm trying to move from the Arduino IDE to Visual Studio Code. I have a program that uses interrupt.h #include <avr/interrupt.h> but it's not being found because it's not on the include path. ...
0
votes
2answers
65 views

Preprocessing problem

I've a little problem, I'm trying to create a library with processor variables for tune it. So in .ino I declared my preprocessor var, but preprocessor variables appear not defined in my library. (...