Questions tagged [c-preprocessor]

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

Filter by
Sorted by
Tagged with
0
votes
4answers
64 views

How to link a computer processor to an Arduinno on a board? [closed]

I am completely new to Arduinno, so please forgive if the question is stupid. Here is the problem: I have a project where I want an Arduino (or similar microchip board) to handle some sensors and ...
1
vote
1answer
182 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: ...
2
votes
1answer
59 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(...
6
votes
2answers
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. ...
15
votes
4answers
12k 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 ...
0
votes
1answer
84 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::...
23
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; ...
2
votes
1answer
173 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 ...
1
vote
2answers
104 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. (...