Pages: [1]   Go Down
Author Topic: LedControl library fails in Arduino IDE 0012  (Read 1482 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#include "LedControl.h"
void setup() {}
void loop() {}

The errors are:
Code:
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?
Logged

Austin, TX USA
Offline Offline
God Member
*****
Karma: 4
Posts: 997
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, a workaround for this problem is to open the file hardware/cores/arduino/wiring.h and change

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

to

Code:
[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
« Last Edit: October 02, 2008, 09:45:42 pm by mikalhart » Logged

Austin, TX USA
Offline Offline
God Member
*****
Karma: 4
Posts: 997
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Wuppertal/Germany
Offline Offline
God Member
*****
Karma: 1
Posts: 895
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Wuppertal/Germany
Offline Offline
God Member
*****
Karma: 1
Posts: 895
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: