Questions tagged [c-preprocessor]
the macro preprocessor for the C and C++ computer programming languages.
10
questions
1
vote
0answers
27 views
Getting error while using conditional preprocessor to define macro [closed]
int parity = 1;
// DATA, PARITY, and STOP BITS SETTINGS
#if parity == 1
#define PARITY SERIAL_8N1
#elif parity == 2
#define PARITY SERIAL_8O1
void setup()
{
Serial.begin(9600, PARITY)
}
...
0
votes
4answers
61 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
150 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
43 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(...
0
votes
1answer
76 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::...
2
votes
1answer
142 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 ...
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.
...
1
vote
2answers
92 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. (...
13
votes
4answers
10k 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 ...
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;
...