StandardCplusplus icon indicating copy to clipboard operation
StandardCplusplus copied to clipboard

expected unqualified-id before 'long'

Open jefferai opened this issue 11 years ago • 6 comments

I'm trying to use this library and hitting a problem. Below is the (verbose) output. I did notice that the StandardCplusplus.h include does an #undef abs, which I'm assuming is related to this, but including that file or not made no difference in my project. Any ideas?...thanks in advance.

[ 68%] Building CXX object CMakeFiles/hub.dir/src/main.cpp.obj /home/jmitchell/Arduino/avr8-gnu-toolchain-linux_x86_64/bin/avr-g++ -DUBRRH -DUBRR0H -DUBRR1H -DUBRR2H -DUBRR3H -DDEBUG_K=1 -g -Os -mcall-prologues -ffunction-sections -fdata-sections -fno-exceptions -I/home/jmitchell/Arduino/libraries/Arduino-Style/StandardCplusplus -I/home/jmitchell/Arduino/libraries/messaging -I/home/jmitchell/Arduino/arduino-1.0.1/libraries -I/home/jmitchell/Arduino/arduino-1.0.1/hardware/arduino/variants/mega -DF_CPU=16000000L -DARDUINO=100 -mmcu=atmega2560 -I/home/jmitchell/Arduino/arduino-1.0.1/hardware/arduino/cores/arduino -I/home/jmitchell/Arduino/arduino-1.0.1/libraries -I/home/jmitchell/Arduino/arduino-1.0.1/hardware/arduino/variants/mega -I/home/jmitchell/Arduino/libraries/Arduino-Style/SoftwareSerial -I/home/jmitchell/Arduino/arduino-1.0.1/libraries/Wire -I/home/jmitchell/Arduino/libraries/Arduino-Style/Usb -I/home/jmitchell/Arduino/libraries/Arduino-Style/AndroidAccessory -I/home/jmitchell/Arduino/libraries/Arduino-Style/DebugPrint -I/home/jmitchell/Arduino/libraries/Arduino-Style/Time -o CMakeFiles/hub.dir/src/main.cpp.obj -c /home/jmitchell/Arduino/applications/hub/src/main.cpp In file included from /home/jmitchell/Arduino/libraries/Arduino-Style/StandardCplusplus/memory:22:0, from /home/jmitchell/Arduino/libraries/Arduino-Style/StandardCplusplus/char_traits:22, from /home/jmitchell/Arduino/libraries/Arduino-Style/StandardCplusplus/iosfwd:21, from /home/jmitchell/Arduino/libraries/Arduino-Style/StandardCplusplus/iterator:21, from /home/jmitchell/Arduino/applications/hub/src/main.cpp:32: /home/jmitchell/Arduino/libraries/Arduino-Style/StandardCplusplus/cstdlib:60:14: error: expected unqualified-id before 'long' /home/jmitchell/Arduino/libraries/Arduino-Style/StandardCplusplus/cstdlib:60:14: error: expected ')' before 'long' /home/jmitchell/Arduino/libraries/Arduino-Style/StandardCplusplus/cstdlib:60:14: error: expected ')' before 'long'

jefferai avatar Sep 18 '12 22:09 jefferai

Oh, I'm using Atmel's official toolchain: gcc version 4.6.2 (AVR_8_bit_GNU_Toolchain_3.4.0_663)

jefferai avatar Sep 18 '12 22:09 jefferai

I had this issue when I only had:

#include StandardCplusplus.h #include vector

I then added the rest of the header files listed in the string-vector example and no longer saw this error message.

ryantuck avatar Dec 05 '12 19:12 ryantuck

Hi! I have the exact same error message and ryantucks tip didn't work. I have all includes of the string-vector example in my test program :-/

widarr avatar Oct 13 '13 20:10 widarr

I have tried again and I can't even get the example to work the ŕesult is always:

/home/vidar/sketchbook/libraries/StandardCplusplus/cstdlib:60: error: expected unqualified-id before ‘long’ /home/vidar/sketchbook/libraries/StandardCplusplus/cstdlib:60: error: expected )' before ‘long’ /home/vidar/sketchbook/libraries/StandardCplusplus/cstdlib:60: error: expected)' before ‘long’

I would really like to use this lib though :-/

widarr avatar Oct 20 '13 12:10 widarr

This is because the builtin Arduino.h contains the line #define abs ..., which then ruins the function definition.

This is fixed with #include "StandardCplusplus.h" at the top of all your files, although arguably #undef abs should appear within cstdlib.

eric-wieser avatar Jan 21 '14 18:01 eric-wieser

I include Arduino.h after including another C++ library like std::vector and this issue is fixed.

0x0c avatar Nov 20 '14 15:11 0x0c

Hi there,

GH-34 has a fix for this, as suggested by @eric-wieser -- thanks! We are hosting a working version at ^1 on behalf of the next branch. Pulling in the StandardCplusplus library by using a PlatformIO configuration like outlined below works for us.

With kind regards, Andreas.

[platformio]
src_dir = .

[env:atmega328p]
platform = atmelavr@^2
board = uno
framework = arduino
lib_deps =
    https://github.com/hiveeyes/StandardCplusplus#next

amotl avatar May 26 '23 23:05 amotl

Merged #34 which fixes this. Thanks!

maniacbug avatar Jul 05 '23 22:07 maniacbug

Wow. Fun to see my bug from 11 years ago get closed! Just a lovely unexpected GitHub notification.

jefferai avatar Jul 06 '23 14:07 jefferai