Skip to main content
Share Your Experience: Take the 2024 Developer Survey
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/...
James Waldby - jwpat7's user avatar
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 ...
chrisl's user avatar
  • 16.3k
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 ...
Majenko's user avatar
  • 105k
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,...
Michel Keijzers's user avatar
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 ...
Majenko's user avatar
  • 105k
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 ...
ocrdu's user avatar
  • 1,795
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 ...
Majenko's user avatar
  • 105k
4 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 ...
Nick Gammon's user avatar
  • 38.3k
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 ...
chrisl's user avatar
  • 16.3k
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> &...
Ho Chung Law's user avatar
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 ...
jsotola's user avatar
  • 1,515
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;
user2455016's user avatar
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: ...
John Burger's user avatar
  • 1,875
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 ...
Majenko's user avatar
  • 105k
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 ...
Nick Gammon's user avatar
  • 38.3k
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 ...
per1234's user avatar
  • 4,178
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 ...
Michel Keijzers's user avatar
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 ...
Kwasmich's user avatar
  • 1,513
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 (...
timemage's user avatar
  • 5,299
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 ...
Majenko's user avatar
  • 105k
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 ...
Majenko's user avatar
  • 105k
2 votes
Accepted

Removing the L from F_CPU in assembly

You have an XY problem: You want to busy-wait some cycles depending on the system's clock frequency. You think you can realize that with (inline) assembly and a repetition macro. But as you found, the ...
the busybee's user avatar
  • 2,078
2 votes

Removing the L from F_CPU in assembly

Just as a complement to the busybee's answer: the avr-libc provides the macros _delay_ms() and _delay_us() for busy-wait delays. Internally, they use __builtin_avr_delay_cycles() and F_CPU to provide ...
Edgar Bonet's user avatar
  • 43.2k
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 ...
chrisl's user avatar
  • 16.3k
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[...
Juraj's user avatar
  • 18k
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 ...
Peter's user avatar
  • 365
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: ...
siliconchris's user avatar
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 ...
James Waldby - jwpat7's user avatar
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 ...
Ryan T's user avatar
  • 11
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
MatsK's user avatar
  • 1,356

Only top scored, non community-wiki answers of a minimum length are eligible