Go Down

Topic: IDE 0013: error compiling (WProgram.h stlib.h) (Read 1 time) previous topic - next topic

mtz

I have a sketch that works with the IDE 0011 (Windows Vista), I've just installed the new version (IDE 0013) but I can't compile because it gives me an error.

This is the error:

In file included from C:\Program Files\arduino-0013\hardware\cores\arduino/WProgram.h:4,
c:/program files/arduino-0013/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'
c:/program files/arduino-0013/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'
c:/program files/arduino-0013/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'
In file included from C:\Program Files\arduino-0013\hardware\cores\arduino/WProgram.h:6,

Can anybody help me?
Thanks in advance.

mtz

halley

On that line in avr's stdlib.h is the declaration for int abs(int).

Did you mix up the files with prior versions of the IDE?  Did you call the abs() function with an argument that was cast to integer with this syntax:  int(x) ?  Do any tabs of your sketch end in the .c filename instead of .cpp?

mtz

No, I don't. Only I put my own librarys...
In any library nor skecth I use abs() function...

Maybe I've files ended in .c in the librarys...

mikalhart

#3
Feb 12, 2009, 06:30 pm Last Edit: Feb 12, 2009, 06:30 pm by mikalhart Reason: 1
No, the problem here is caused by the fact that in wiring.h we still for some reason define our own version of abs.

I'm glad we removed all the #define int... etc. from 0012, but I really think we should also remove the definitions for macros that are also #defined elsewhere, especially since stdlib.h seems to be automatically included these days.

You might try simply adding

Code: [Select]
#undef abs

at the top of your sketch right after all the #include lines.

Mikal

mtz

Yeah...

You have been faster than me... I found it too...

Thanks a lot...

wjoojoo

I found the exact same problem when I compiled a sketch I'm working on to control some servo motors with the Servo Library I downloaded from the "Contributed Libraries" section of the arduino website.

When I add the "#undef abs" line underneath my #include lines I get the same error message except now it says 'double' instead of 'int'.

I am so confused!

enzo

I had exactly the same problem as you wjoojoo and someone on IRC told me to add #include <WProgram.h> at the right beginning of my sketch, and it works now

GrahamC

Yupp - just come across exactly the same problem on 0014.  Adding [font=Courier]#include <WProgram.h>[/font] before any other #includes fixes it...   ;D

kdogzxc

i think i am having the same problem as wjoojoo. i have some servos that i want to control with the servotimetimer1 library but it is giving me hell. i have tried all the stuff suggested in old posts.

initially it was giving me the
In file included from C:\Program Files\arduino-0013\hardware\cores\arduino/WProgram.h:4,
c:/program files/arduino-0013/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'
c:/program files/arduino-0013/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'
c:/program files/arduino-0013/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'
In file included from C:\Program Files\arduino-0013\hardware\cores\arduino/WProgram.h:6,

i #included the <WProgram.h> and this allowed it to compile but it still will not control my servos. so i went on to changes:
TIMSK0 &= ~(_BV(TICIE1) | _BV(OCIE1A) | _BV(OCIE1B) | _BV(TOIE1) );
   to:
TIMSK0 &= ~(_BV(OCIE1A) | _BV(OCIE1B) | _BV(TOIE1) );
   and then to:
TIMSK0 &= ~( _BV(ICIE1) | _BV(OCIE1A) | _BV(OCIE1B) | _BV(TOIE1) );

and still nothing

any help to get this library working or info on how to control some servos more accurately than the servo library can do would be great.

mem

#9
Mar 16, 2009, 08:44 pm Last Edit: Mar 16, 2009, 08:45 pm by mem Reason: 1
Quote
i have some servos that i want to control with the servotimetimer1 library


why not use the Servo library distributed with Arduino 0012 and later,
It looks functionally the same to me.

kdogzxc

you can only control a servo with accuracy of a degree. I want to be able to turn a servo half a degree if i wanted to.

mem

#11
Mar 16, 2009, 09:28 pm Last Edit: Mar 16, 2009, 09:31 pm by mem Reason: 1
Quote
you can only control a servo with accuracy of a degree. I want to be able to turn a servo half a degree if i wanted to.
perhaps you are looking at a different library, my copy of ServoTimer1 has the same capabilities (and limitations) as Servo.

BTW, half a degree is about 0.3% of the movement of the servo. I would be (pleasantly) surprised if the pot and feedback circuit of a servo was half that accurate.

kdogzxc

im looking at the servotimetimer1 library and i thought that that would allow you to enter the pulse you want rather than the degree you want. if i could enter the pules i want im am only limited by the servo like you said. but if i can only enter the degree i am limited by the library. like if 0 degrees is a 600ms pulse and 1 degree is 610, i want to be bale to enter the 605 that servotimetimer1 allows not only the 1 or 0 that servo allows.

mem

Can you post a link to the ServoTime1 library that allows input in microseconds

kdogzxc

http://www.arduino.cc/playground/ComponentLib/Servotimetimer1

this is the one that i cannot get to work, the normal servo library works fine.

Go Up