Skip to main content

Questions tagged [c-preprocessor]

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

Filter by
Sorted by
Tagged with
3 votes
2 answers

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])...
Giorgos Xou's user avatar
-1 votes
1 answer

Unable to get my created library to work - while it compiles

I am experimenting with creating my own Arduino libraries. Unfortunately, while the program compiles, the end result does not work. For purposes of experimentation, I have broken down the library in ...
user1584421's user avatar
  • 1,405
0 votes
1 answer

#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 ...
stevo's user avatar
  • 51
-1 votes
1 answer

Char Array in PreProcessor

I need to define an array, that later on will be the name of a class, and will be pointed to. For example (in a non pre-processor way): const char *button_names[4]={"b0","b1","...
guyd's user avatar
  • 1,049
1 vote
0 answers

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 ...
Andrew's user avatar
  • 11
0 votes
2 answers

Odd behavior of defines - is this Arduino specific and how does it work?

A question I have long had regards an interaction between #define statements and a library header include. I've seen several Arduino libraries use this rather convenient configuration system where you ...
user avatar
0 votes
1 answer

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 ...
Z Dhillon's user avatar
0 votes
4 answers

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 ...
totalMongot's user avatar
1 vote
1 answer

#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: ...
Michel Keijzers's user avatar
2 votes
1 answer

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(...
Brethlosze's user avatar
0 votes
1 answer

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::...
Michel Keijzers's user avatar
2 votes
1 answer

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 ...
user1273684's user avatar
6 votes
2 answers

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. ...
Passiday's user avatar
  • 163
1 vote
2 answers

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. (...
Servuc's user avatar
  • 133
21 votes
3 answers

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 ...
CharlieHanson's user avatar
23 votes
4 answers

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; ...
Greenonline's user avatar
  • 3,048