Go Down

Topic: LedControl library fails in Arduino IDE 0012 (Read 1 time) previous topic - next topic

MindSpace

Hi. I've been loving the LEDcontrol library (http://www.arduino.cc/playground/Main/LedControl), but recently upgraded from 0010 to Arduino 0012 IDE, and now unfortunately even compiling the following fails (not just warnings):

Code: [Select]
#include "LedControl.h"
void setup() {}
void loop() {}


The errors are:
Code: [Select]
In file included from C:\Users\User\Desktop\ecw\Arduino Coding\arduino-0012\hardware\cores\arduino/WProgram.h:4,


c:/users/user/desktop/ecw/arduino coding/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected unqualified-id before 'int'


c:/users/user/desktop/ecw/arduino coding/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected `)' before 'int'


c:/users/user/desktop/ecw/arduino coding/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected `)' before 'int'


c:/users/user/desktop/ecw/arduino coding/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'


c:/users/user/desktop/ecw/arduino coding/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'


c:/users/user/desktop/ecw/arduino coding/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'


c:/users/user/desktop/ecw/arduino coding/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected identifier before '(' token


c:/users/user/desktop/ecw/arduino coding/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected `)' before '(' token


c:/users/user/desktop/ecw/arduino coding/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected ',' or '...' before '(' token


c:/users/user/desktop/ecw/arduino coding/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected initializer before ')' token


c:/users/user/desktop/ecw/arduino coding/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:176: error: '__compar_fn_t' has not been declared


In file included from C:\Users\User\Desktop\ecw\Arduino Coding\arduino-0012\hardware\cores\arduino/WProgram.h:6,


It worked (with warnings) in 0011 and worked fine in 0010.
I've replicated the errors above in XP Pro  and Vista.

Has anyone else tried this?

mikalhart

#1
Oct 03, 2008, 04:04 am Last Edit: Oct 03, 2008, 04:45 am by mikalhart Reason: 1
Ok, a workaround for this problem is to open the file hardware/cores/arduino/wiring.h and change

Code: [Select]
#define int(x)     ((int)(x))
#define char(x)    ((char)(x))
...
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ((x)*(x))


to

Code: [Select]
[glow]#if 0 // remove this block![/glow]
#define int(x)     ((int)(x))
#define char(x)    ((char)(x))
...
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ((x)*(x))
[glow]#endif[/glow]


These definitions, in particular int, double, float, round and abs, seem to collide with the standard C/C++ headers.

Mikal

mikalhart

If you find modifying system headers distasteful, I think adding the following lines AFTER the #include "LedControl.h" should also resolve the problem:

#include "LedControl.h"
#undef int
#undef abs
#undef double
#undef float
#undef round


Mikal

wayoda

Hi,
here is a workaround where you only have to make some changes to the LedControl-library sources themselfes:

To make the LedControl library compile under arduino-0012 you have to do the following:
1. Download and unzip the library code to arduino-0012/hardware/libraries (Standard procedure, you probably did that already)
2. Open the file LedControl.h with your favorite Editor and change the line
#include <WConstants.h>
to
#include <WProgram.h>
3. Open the file LedControl.cpp with your favorite Editor and delete the line
#include "WProgram.h"

Now the library should compile (with a warning about a missing newline which can be safely ignored)

I will come up with a real bugfix after my holidays which start right now.

Eberhard

wayoda

I have just uploaded a bugfix release of the library to the playground, that compiles under arduino-0010 up to arduino-0012.

http://www.arduino.cc/playground/Main/LedControl

(pre 0010 versions should also work, but I'd rather suggest to update your arduino-version if you still run this old stuff)

Eberhard

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy