7

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 output for compilation in the preferences of your Arduino IDE, you can actually see, what calls to GCC the IDE is doing. You could use that to replicate it. If ...


7

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 case of simple functions and classes there's no problem - the linker is intelligent enough to work it out and only link in the functions that are actually used. ...


7

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/include-fixed/limits.h or with hardware/tools/avr/lib/gcc/avr/4.8.1/install-tools/include/limits.h and contain definitions like the following. /* Maximum value an ...


6

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 purely constants or literals will be replaced at compile time with the result. For instance, the code: const int a = 3; const int b = 4; void setup() { int ...


5

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 not for external stuff.


4

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 webpage[] PROGMEM = R"=====( <html> <head> <script src=\"https://cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.6/svg.min.js\"></script>...


4

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 really want to: I think you can use flags to tell the compiler, that this shouldn't be optimized out. I'm no expert in this, others might know more about this ...


3

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, change Servo motor1, motor2, motor3, motor4; Servo motorArray[4] = {motor1, motor2, motor3, motor4}; to extern Servo motor1, motor2, motor3, motor4; extern ...


3

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> </body> </html> )=="=="; inspired by answer provided by @jsotola if i used the syntax like this R"=="==()=="==" the link will become inside the ...


3

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 function (the auto-inserted this parameter) is volatile: class Timer{ private: uint32_t start_time; public: Timer(){ start_time=millis(); } ...


2

You have been bitten by a bug in the compiler toolchain. The bug has already been reported. Suggested workarounds: add a few unused global variables add some unused functions.


2

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 warnings: /tmp/arduino_modified_sketch_857720/sketch_aug31a.ino: In function 'void setup()': /tmp/arduino_modified_sketch_857720/sketch_aug31a.ino:1:25: warning: ...


2

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 specify that a function is to be compiled with different optimization options than specified on the command line. Arguments can either be numbers or strings. ...


2

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 you have installed to the libraries subfolder of your sketchbook Libraries bundled with the hardware package of the currently selected board - Hardware package of ...


2

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: here's the answer! Now all we need to do is get the maintainers of all the libraries to put these in... and fix the other warnings...


2

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 AVR platform, for obvious reasons). Also it is internally hardwired to run code from the flash memory. You cannot execute code from RAM. The Arduino is a ...


2

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 of supporting multiple files (having horizontal tabs make the number of files to see max 6 or 7, and using .h/.cpp files easily goes most beyond that number). ...


2

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 libraries work, and port the sketch to the ESP32 once you have learned how.


1

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 (16128 + 16384) * 8 == 260096 bytes of memory. There's only 262144 bytes of RAM in entirety. The way the linker script is set up at least 1024 bytes are reserved ...


1

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[0] in Serial.print(pat[0],HEX); is an item in a constant array const uint8_t pat[]. it can't change at runtime so the compiler uses the value 0xFF. that is why ...


1

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) archive them into a library file. Do the same for the core. Then you need to add paths to your sketch compilation command pointing to where the header files are for ...


1

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 are missing. This is why when you "compile" with the IDE, it copies the files in a temp folder, add some lines at beginning of theses files and then call the ...


1

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: numberOfFiles = countFiles(SD.open(plrCurrentFolder)); That way, the directory get's opened and my function can operate on it. I see I still have to learn a lot :-)


1

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 integer type Thus, in the evaluation of bx_0 | bx_1 within the statement const byte pinMask[3] = {bx_0, bx_1, bx_0 | bx_1};, the operands bx_0 and bx_1 are ...


1

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 website in the upper right corner. The Link was download website. Then the path was pjrc_2017_04_04\teensy\td_136


1

The problem is that you have incorrectly installed the ESP32 hardware package. If you look at the official installation instructions: https://github.com/espressif/arduino-esp32/blob/master/README.md#installation-instructions you'll see that the architecture folder should be named esp32, not ESP32 as you have named your folder. When multiple libraries ...


1

#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

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. The main use of constants is to act as a remainder that you cannot change that value. My personal experience tells me that const occupy the same RAM that int ...


1

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 the starting point for most questions. If you Google for: maximum unsigned long in c++ You will find the first link leads to: http://www.cplusplus.com/...


1

In WString.h is a define: #define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal))) In other words, the letter F is already a macro. I don't know what your code: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z is supposed to do. I suppose you are just testing the syntax highlighting? The syntax ...


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