very confused by compiler error

I just installed the LEDcontrol library, grabbed some sample code off the net, and I get a error compiling message. I have not changed the sample code in any way, so it should compile...

Can anyone give me any hints how to fix this?

Error:

C:\Program Files\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 -IC:\Program Files\Arduino\hardware\arduino\cores\arduino -IC:\Program Files\Arduino\libraries\LedControl C:\DOCUME~1\db\LOCALS~1\Temp\build6588463415627815450.tmp\timer_1.cpp -oC:\DOCUME~1\db\LOCALS~1\Temp\build6588463415627815450.tmp\timer_1.cpp.o
In file included from C:\Program Files\Arduino\hardware\arduino\cores\arduino/WProgram.h:6,
from timer_1.cpp:14:
c:/program files/arduino/hardware/tools/avr/lib/gcc/../../avr/include/math.h:439: error: expected unqualified-id before 'double'
c:/program files/arduino/hardware/tools/avr/lib/gcc/../../avr/include/math.h:439: error: expected )' before 'double' c:/program files/arduino/hardware/tools/avr/lib/gcc/../../avr/include/math.h:439: error: expected )' before 'double'

#include <LedControl.h>

//We always have to include the library
#include "LedControl.h"

/*
 Now we need a LedControl to work with.
 ***** These pin numbers will probably not work with your hardware *****
 pin 10 is connected to LOAD 
 pin 11 is connected to the CLK 
 pin 12 is connected to the DataIn 
 We have only a single MAX72XX.
 */
LedControl lc=LedControl(12,11,10,1);

/* we always wait a bit between updates of the display */
unsigned long delaytime=250;

void setup() {
  /*
   The MAX72XX is in power-saving mode on startup,
   we have to do a wakeup call
   */
  lc.shutdown(0,false);
  /* Set the brightness to a medium values */
  lc.setIntensity(0,8);
  /* and clear the display */
  lc.clearDisplay(0);
}


/*
 This method will display the characters for the word "Arduino" one after the other on digit 0. 
 */
void writeArduinoOn7Segment() {     
  lc.setChar(0,0,'a',false);
  delay(delaytime);
  lc.setRow(0,0,0x05);
  delay(delaytime);
  lc.setChar(0,0,'d',false);
  delay(delaytime);
  lc.setRow(0,0,0x1c);
  delay(delaytime);
  lc.setRow(0,0,B00010000);
  delay(delaytime);
  lc.setRow(0,0,0x15);
  delay(delaytime);
  lc.setRow(0,0,0x1D);
  delay(delaytime);
  lc.clearDisplay(0);
  delay(delaytime);
} 

/*
  This method will scroll all the hexa-decimal
 numbers and letters on the display. You will need at least
 four 7-Segment digits. otherwise it won't really look that good.
 */
void scrollDigits() {
  for(int i=0;i<13;i++) {
    lc.setDigit(0,3,i,false);
    lc.setDigit(0,2,i+1,false);
    lc.setDigit(0,1,i+2,false);
    lc.setDigit(0,0,i+3,false);
    delay(delaytime);
  }
  lc.clearDisplay(0);
  delay(delaytime);
}

void loop() { 
  writeArduinoOn7Segment();
  scrollDigits();
}

Post the code. And links to the libraries.

Sounds similar to this:

link to library:

http://www.wayoda.org/arduino/ledcontrol/index.html#Download

I noticed that if I delete ALL the sample code, but leave just that .include ONLY, I still get that error.

If I try to use the a different library - the standard matrix library as a test, I also get an error:
Could I have some weird problem with my installation?
(I also use NewSoftserial and that works great!)

C:\Program Files\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 -IC:\Program Files\Arduino\hardware\arduino\cores\arduino -IC:\Program Files\Arduino\libraries\Matrix C:\DOCUME~1\db\LOCALS~1\Temp\build1098526400343394504.tmp\timer_1.cpp -oC:\DOCUME~1\db\LOCALS~1\Temp\build1098526400343394504.tmp\timer_1.cpp.o
C:\Program Files\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 -IC:\Program Files\Arduino\hardware\arduino\cores\arduino -IC:\Program Files\Arduino\libraries\Matrix -IC:\Program Files\Arduino\libraries\Matrix\utility C:\Program Files\Arduino\libraries\Matrix\Matrix.cpp -oC:\DOCUME~1\db\LOCALS~1\Temp\build1098526400343394504.tmp\Matrix\Matrix.cpp.o
C:\Program Files\Arduino\libraries\Matrix\Matrix.cpp:41:20: error: Sprite.h: No such file or directory
C:\Program Files\Arduino\libraries\Matrix\Matrix.cpp: In member function 'void Matrix::write(uint8_t, uint8_t, Sprite)':
C:\Program Files\Arduino\libraries\Matrix\Matrix.cpp:202: error: 'sprite' has incomplete type
C:\Program Files\Arduino\libraries\Matrix/Matrix.h:25: error: forward declaration of 'struct Sprite'

#include <Matrix.h>

Matrix myMatrix = Matrix(5, 7, 6);

void setup()
{
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
}

void loop()
{
  delay(500);
}

Well this makes the error go away, I can't promise the code will work...

As I mentioned in the other thread, "round" is declared in two rather different ways.

Find wiring.h file and comment out this line:

#define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

eg.

Change it to:

// #define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

It seems to clash with the function prototype in math.h. I don't know why this error doesn't occur more frequently, and perhaps the maintainers of the IDE might take a look at this.

I'm not sure if this is the best solution.

If you have a ATMega328 based arduino,
then
LedControl lc=LedControl(12,11,10,1);
are not the SPI pins that you would connect a MAX7219 etc to.
You would need 13,12, 11 and some pin for CS.

Unless the code is doing some software bitbang SPI thing.

Nick,

Your message show the code to comment out, but the code to replace it with is the same cut and paste. Can you resend?
Thanks.

The code to replace with has a comment at the start.

In other words, find that line and put "//" at the start of it.

Ah, simply comment out that line? Will try it.

ok, I have commented out that line, and it seems to work.
Much appreciated.

Now can you shed some light on what we did, and why it needed to be done? Will if affect anything else?

In wiring.h we have this:

#define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

and in math.h we have:

double round (double __x) __ATTR_CONST__;

I don't see how they can work together.

It seems to me that the writers of those two, different, ways of expressing the "round" idea were not aware of each other. Since a define results in simple text substitution the phrase "round (double __x)" in the function prototype in math.h is replace by "((x)>=0?(long)((x)+0.5):(long)((x)-0.5))" after the compiler changes each "x" to read "double __x". So basically you get garbage.

What I don't understand is why this clash doesn't manifest itself more often. Often enough, say, for the developers of the IDE environment to get very concerned and reword one of them. For example changing wiring.h to read:

#define roundup(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

Now there is no clash between the two words "round".

I'll have to presume that certain combinations of things cause math.h to be included, thus triggering the problem.

I doubt it will cause major problems, except in code that does rounding perhaps. Then they may get method B rather than method A. Whether that makes a real difference I'm not sure.

That does seem troublesome.

Is there some standard way to report such an issue to get an official response?

My hope is that the senior developers, who have the power clear this up, read this forum. I don't know for sure if that is the case. Nor do I know of any other way of contacting them. Perhaps someone else does?

Hi Nick,

Have a look at this:
http://arduino.cc/forum/index.php/topic,71595.0.html