Problems using older Arduino sketches

This isn’t a comprehensive guide yet, but I’d like it to be: Things You Need To Change For New Arduino Versions.

1: void write(uint8_t x);
The error returned:
…foo.c: error: conflicting return type specified for ‘void foo::bar(uint8_t)’
…foo.c:23: error: overriding ‘virtual size_t Print::write(uint8_t)’
The solution:
size_t write(uint8_t x);

Problem #2: WProgram.h changed to Arduino.h
The error returned: Most common core functions like pinMode, digitalWrite, digitalRead, analogRead, etc, will error out as undefined. At the top of the slough of errors you will find “WProgram.h: No such file or directory”
The solution: Use a preprocessor directive to determine the version and automatically call the proper include.
#if defined(ARDUINO) && ARDUINO >= 100
#include “Arduino.h”

#else
#include “WProgram.h”
#endif

Hopefully this will fix your compiling problems.

Leave a Reply

Your email address will not be published. Required fields are marked *