Arduino IDE – Foutmeldingen en oplossingen

figuur met vergrootglas


Foutmelding: fatal error: WConstants.h: No such file or directory

Krijg je deze Arduino IDE foutmelding: WConstants.h: No such file or directory. dan probeer je wellicht een oude bibliotheek of code te compileren van voor Arduino IDE versie 1.00.

Voor Arduino versie 1.00 wordt in een bibliotheek altijd de “core” geladen met: #include <WProgram.h>

Na Arduino versie 1.00 wordt in een bibliotheek altijd de “core” geladen met: #include <Arduino.h>

Je kan eenvoudig de bibliotheek zelf updaten/bijwerken door de regel #include <WConstants.h>  te vervangen met:

Zo is de bibliotheek weer compatibel tot 0023 en 1.0 versies!


Foutmelding: ‘prog_char’ does not name a type

Deze foutmelding treed vaak op als men een oud script van Arduino IDE v1.0.x wil gaan gebruiken in Arduino IDE v1.5.8+, het heeft er mee te maken dat de AVR C++ tools die worden meegeleverd bij de Arduinio IDE zijn bijgewerkt naar een nieuwere versie, en hier zijn strenge voorwaarden en andere restricties van toepassing:

Voorbeeld: Vervang de regel met const prog_char

const prog_char string_a[] PROGMEM = "

met const char

const char string_a[] PROGMEM = "

Informatie en toelichting (ENG):

The short answer is that the newer IDE is shipping with a newer avr-gcc  toolset and some of the older ways of doing things no longer work. However, there are ways of doing declarations that work with both the new and the old avr-gcc  toolset.

A bit more information.
Things like prog_char, progmem, PROGMEM, etc.. are not part of Arduino nor the IDE.  They are AVR specific and are technically not part of gcc. They are proprietary AVR capabilities provided by AVR libC which is included with the avr version of gcc.

The progmem stuff is kind of a hack that allows using FLASH storage for constant data since the internal AVR h/w architecture does not allow it to use the normal C language constructs for constant data that can be used on other processors like ARM, pic32, x386, 68k, etc… i.e. the AVR couldn’t store constant data in flash because its architecture was incompatible with C’s notion of address space.

Because the AVR progmem stuff was implemented as kind of hack in the libC library  vs being really supported by the compiler,  it has some issues particularly with C++, and that is why you get warnings when it is used in C++.

The AVR progmem stuff also played a bit fast and loose with some of the rules.

As avr-gcc has been updated over the years,  changes and additional modifications/updates have been made to the actual compiler to better support Harvard architectures like the AVR, which
has required that some changes also had to be made to the AVR progmem stuff.
As a result some of the earlier progmem definitions have been changed, deprecated, or have been removed. Also some of the syntax that was technically incorrect still worked with the older compilers no longer works with the newer compiler.
In fact, many of the examples on the Arduino progmem page were wrong and were in that “technically incorrect but worked” category.

The prog_ data types have been deprecated for quite some time. The Arduino has been shipping old versions of the avr-gcc tools but now with the newer compiler, they no longer work.

Bron: forum.arduino.cc


Foutmelding: fatal error: wiring.h: No such file or directory

Krijg je deze Arduino IDE foutmelding: wiring.h: No such file or directory. dan probeer je wellicht een oude bibliotheek of code te compileren van voor Arduino IDE versie 1.00.

Voor Arduino versie 1.00 wordt in een bibliotheek altijd de “core” geladen met: #include <wiring.h>

Na Arduino versie 1.00 wordt in een bibliotheek altijd de “core” geladen met: #include <Arduino.h>

Je kan eenvoudig de bibliotheek zelf updaten/bijwerken door de regel #include <WConstants.h>  te vervangen met:

Zo is de bibliotheek weer compatibel tot 0023 en 1.0 versies!


Foutmelding: error: invalid conversion from ‘const char*’ to ‘char’ [-fpermissive]

Vervang bijvoorbeeld:

char c = "i";

naar:

char c = 'i';


Foutmelding: Stray ‘\’ in program.

Krijg je deze Arduino IDE foutmelding: Stray ‘\’ in program. dan heb je wellicht (unicode) tekst van een internetpagina gekopieerd en geplakt in de Arduino IDE.

Stappen die je kunt ondernemen voor het controleren van de code:

1) Controleer de lange min  (long dash), deze moet kort zijn
2) Contoleer de aanhalingstekens   (double quote), deze moeten zijn "

Hieronder zie je een voorbeeld:

arduino stray in program


Foutmelding: expected unqualified-id before ‘if’

Heb je waarschijnlijk “losse” code gebruikt?, alle code moet in functies staan! (muv het verklaren van variabelen)