9
votes
Accepted
Is there a constant for the Maximum Unsigned Long value in an Arduino compiler?
Various limits.h files in the avr-gcc hierarchy define ULONG_MAX, which may be the value you want. For example, on my system such files have paths ending with hardware/tools/avr/lib/gcc/avr/4.8.1/...
7
votes
Accepted
Using Arduino as a standalone compiler
First of all: The Arduino IDE brings its own GCC compiler. It is a version, that can compile for the AVR platform (don't know, if the standard version is capable of that).
When you activate verbose ...
6
votes
Accepted
Arduino constant vs Microchip PIC constant
const means different things in different contexts as far as storage goes.
For a simple numeric value the compiler will generally replace the constant with the literal value. Any mathematics using ...
6
votes
Accepted
Multiple definition of "..." Compiler Error
Although the motor (global) variables are defined in a header files, they are included in both cpp files, thus defined twice.
Make them extern, and than define them in the motor.cpp file.
In motor.h,...
6
votes
Accepted
Does the compiled binary of a sketch include uncalled functions from a library?
In general only the functions actually used by your code are included in the final linkage of the binary.
However it's not always possible for the compiler to know what is used and what isn't.
In the ...
5
votes
Accepted
Can't use uint16_t in library
Using #include <Arduino.h> in your myheader.h will also include <stdint.h> and probably solve this.
The Arduino IDE automatically includes Arduino.h in the sketch itself, but apparently ...
4
votes
Accepted
Compiling error:passing as 'this' argument
If you want to use an instantiated object as volatile then the functions within it also have to be marked as volatile. That tells the compiler that the instance pointer you will be passing to the ...
4
votes
Accepted
Global array doesn't get assigned the space it would take up in memory
There is no problem here. Only the compiler is a bit smarter than you anticipated. It sees, that you are not using arr anywhere, so it just optimizes it out.
There are two ways to prevent that, if you ...
3
votes
Arduino IDE c++ 11 raw string literal have issues with // in http://, complier thinks // is comment
char webpage[] PROGMEM = R"=="==(
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.6/svg.min.js"></script>
</head>
<body>
&...
3
votes
Arduino IDE c++ 11 raw string literal have issues with // in http://, complier thinks // is comment
Escape the two quote marks inside the string using a backslash (literal quotes).
Without the escape characters, the URL is "outside" of a string because the quote marks are string delimiters.
char ...
3
votes
Accepted
What is the Arduino compiler's version of `__unused` for function parameters?
Well, I typed all that question up for posting, then tried one last thing. It worked!
void Fn(__attribute__((unused)) int param) {
} // Fn(param)
So, rather than let a good question go to waste: ...
3
votes
Is there a constant for the Maximum Unsigned Long value in an Arduino compiler?
Did you try to do this?:
unsigned long maxUnsignedLong = 0UL - 1UL;
or:
const unsigned long ULONG_MAX = 0UL - 1UL;
3
votes
Is there a constant for the Maximum Unsigned Long value in an Arduino compiler?
You don't need "to compensate for a roll over condition".
See my answer: https://arduino.stackexchange.com/a/33577/10794
in an Arduino compiler?
The "Arduino" compiler is a C++ compiler. That is ...
2
votes
Force compiler to execute instructions sequentially?
You can use the optimize function attribute to change the compiler optimization level for an individual function. That's the closest you'll get.
optimize
The optimize attribute is used to ...
2
votes
GCC msg "note: in definition of macro 'max'" error message
I can reproduce your message easily enough:
#define max(a,b) ((a)>(b)?(a):(b))
void setup() {
int b = 66;
unsigned int c = 42;
analogWrite (3, max (b, c));
}
void loop() { }
I get these ...
2
votes
Accepted
Why are some letters reserved?
The Arduino IDE does keyword coloration according to a very crude system. It simply scans for all the keywords.txt files included with:
Arduino IDE
Libraries bundled with the Arduino IDE
Libraries ...
2
votes
Using Arduino as a standalone compiler
This is not an answer that fully meets what you ask, but it is too big for a comment, and it helps you somewhat, at least using your Sublime editor.
What annoys me most in the Arduino IDE is the lack ...
2
votes
Arduino IDE - scope of the pre-processor "#define"
The scope of a #DEFINE macro is the translation unit. That is the current .c or .cpp file that is currently being compiled.
In you code PIN_NUMBER is defined in test.ino. The #include macro literaly ...
2
votes
Accepted
ld.exe:linker_script.ld:138 cannot move location counter backwards | ArduinoFFT Error
Short Version
The short answer is that you've exhausted RAM.
These two arrays alone:
const uint16_t samples = 16128;
double vImag[samples] = {0};
double double_buffer[16384] = {};
...are occupying (...
2
votes
Accepted
Problems with compiling more then one sketch in the Arduino IDE
That sketch is written for the ESP8266, not the ESP32. The two are very different chips, and the libraries used are very different.
You will have to learn how the sketch works, and how the ESP32 ...
2
votes
Accepted
How to make the compiler ensure that local variables memory allocation won't cause any RAM overflow during execution?
You are describing "memory profiling" and is not typically a feature of C or C++. It is more common in higher level languages, such as Java, but C is a considered a much lower level ...
1
vote
Runtime compilation
No, not feasable, not possible.
The Arduino runs machine code and it does not have enough space or computation power for a compiler (also there is simply no version of the avr C++ compiler for the ...
1
vote
Accepted
Weird problem with arduino
If you want to get a value from PROGMEM you must read it with pgm_read functions. Read the PROGMEM reference.
for (int i = 0; i < 8; i++) {
Serial.print(pgm_read_byte_near(pat + i),HEX);
}
pat[...
1
vote
Is there an open source compiler for Arduino Sketch codes?
Just have a look here https://github.com/arduino/Arduino/wiki/Build-Process to understand the process.
In fact Arduino code is not "C or C++" at 100%. You can't compile directy as some informations ...
1
vote
Pass a char array to a function that uses File as parameter
OMG. I'm so sorry for posting such a stupid question. And I'm also sorry for not seeing the obvious even after Majenko pointed me to it.
Of course I need to call the function like this:
...
1
vote
Accepted
What is causing this 'narrowing conversion' warning?
That warning message arises when a compiler complies with C/C++ specifications.
According to ISO/IEC 9899:2011 part 6.5.12.2 (“Bitwise inclusive OR operator”),
Each of the operands shall have ...
1
vote
Error Compiling to Board Teensy LC
I experienced a similar error. Upon further research it seems to be a known issue. I was able to compile using 1.8.2 and Teensyduino 1.36 I accessed 1.36 from downloading the zip file of the pjrc ...
1
vote
Duplicate libraries while compiling for ESP32 in the Arduino IDE
#include "filename.h" will look in the sketch folder
#include <filename.h> will look in the path, defined in File | Preferences, edit preferences.txt, search for sketchbook.path
1
vote
Accepted
Compiling source with Arduino.h with avr-g++
You need to do a whole lot more than just run the one command.
You need to compile each individual source file for the libraries you want (using -c to just compile and not link), then (ideally) ...
1
vote
Arduino constant vs Microchip PIC constant
Constants can still use RAM. The decision whether to store it or not in RAM is up to the compiler. It may, for example, put the constant into RAM and then reference that constant throughout the code. ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
compiler × 36arduino-ide × 5
compile × 5
memory-usage × 5
arduino-uno × 4
esp32 × 3
array × 3
sketch × 3
compilation-errors × 3
memory × 3
arduino-mega × 2
c++ × 2
library × 2
c × 2
teensy × 2
debugging × 2
constants × 2
esp8266 × 1
programming × 1
nodemcu × 1
sd-card × 1
arduino-leonardo × 1
string × 1
avr × 1
avrdude × 1