maniacbug / StandardCplusplus

Standard C++ for Arduino (port of uClibc++)
594 stars 182 forks source link

Library doesn't seem to work with Arduino Due #7

Closed apalazzi closed 1 year ago

apalazzi commented 11 years ago
#include <utility.h>
#include <unwind-cxx.h>
#include <system_configuration.h>
#include <StandardCplusplus.h>
#include <vector>
#include <map>

std::vector<int> myvec;
std::map<String, int> mymap;

void setup()
{
  myvec.push_back(1);
  mymap["test"] = 2;
}

void loop() {}

When compiling for Arduno Due this gives the following error:

Arduino: 1.5.4 (Windows 7), Board: "Arduino Due (Programming Port)"

In file included from prova_cpp_due.ino:2: C:\Users\andrea\Documents\Arduino\libraries\StandardCplusplus/unwind-cxx.h:176: error: ISO C++ forbids casting to an array type 'char [8]' C:\Users\andrea\Documents\Arduino\libraries\StandardCplusplus/unwind-cxx.h:177: error: ISO C++ forbids casting to an array type 'char [8]' C:\Users\andrea\Documents\Arduino\libraries\StandardCplusplus/unwind-cxx.h:178: error: ISO C++ forbids casting to an array type 'char [8]' C:\Users\andrea\Documents\Arduino\libraries\StandardCplusplus/unwind-cxx.h:179: error: ISO C++ forbids casting to an array type 'char [8]' C:\Users\andrea\Documents\Arduino\libraries\StandardCplusplus/unwind-cxx.h:180: error: ISO C++ forbids casting to an array type 'char [8]' C:\Users\andrea\Documents\Arduino\libraries\StandardCplusplus/unwind-cxx.h:181: error: ISO C++ forbids casting to an array type 'char [8]' C:\Users\andrea\Documents\Arduino\libraries\StandardCplusplus/unwind-cxx.h:182: error: ISO C++ forbids casting to an array type 'char [8]' C:\Users\andrea\Documents\Arduino\libraries\StandardCplusplus/unwind-cxx.h:183: error: ISO C++ forbids casting to an array type 'char [8]'

apalazzi commented 11 years ago

Additional info: Arduino IDE 1.5.4 ; when compiled for Arduino Mega 2560 it works.

fawques commented 10 years ago

It doesn't work either with my Arduino DUE, but with different error messages. I show the full compilation messages:

Arduino: 1.5.6-r2 (Windows 8), Placa:"Arduino Due (Programming Port)"

Using library StandardCplusplus in folder: SKETCHBOOK_PATH\libraries\StandardCplusplus (legacy)

C:\Program Files (x86)\Arduino/hardware/tools/g++_arm_none_eabi/bin/arm-none-eabi-g++ -c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=156 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Due" -IC:\Program Files (x86)\Arduino\hardware\arduino\sam\system/libsam -IC:\Program Files (x86)\Arduino\hardware\arduino\sam\system/CMSIS/CMSIS/Include/ -IC:\Program Files (x86)\Arduino\hardware\arduino\sam\system/CMSIS/Device/ATMEL/ -IC:\Program Files (x86)\Arduino\hardware\arduino\sam\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\sam\variants\arduino_due_x -ISKETCHBOOK_PATH\libraries\StandardCplusplus C:\Users\fawques\AppData\Local\Temp\build3473576904558466943.tmp\string_vector.cpp -o C:\Users\fawques\AppData\Local\Temp\build3473576904558466943.tmp\string_vector.cpp.o 

In file included from SKETCHBOOK_PATH\libraries\StandardCplusplus/ostream:28,
                 from SKETCHBOOK_PATH\libraries\StandardCplusplus/istream:24,
                 from SKETCHBOOK_PATH\libraries\StandardCplusplus/serstream:19,
                 from string_vector.ino:2:
SKETCHBOOK_PATH\libraries\StandardCplusplus/ostream_helpers: In static member function 'static void std::__ostream_printout<traits, char, float>::printout(std::basic_ostream<char, traits>&, float)':
SKETCHBOOK_PATH\libraries\StandardCplusplus/ostream_helpers:250: error: there are no arguments to 'dtostrf' that depend on a template parameter, so a declaration of 'dtostrf' must be available
SKETCHBOOK_PATH\libraries\StandardCplusplus/ostream_helpers:250: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)

(Swapped the actual path with SKETCHBOOK_PATH)

esel7353 commented 9 years ago

I have the same error as fawques, but after adding the flag -fpermissive to the boards.txt file, the error message turned to something similar to apalazzis message.

Has anybody found a way to fix this (by e.g. an alternative build process)?

esel7353 commented 9 years ago

I have found a way to get it compiled (probably a very, very bad one). I'm working on ubuntu 14.04 with arduino IDE 1.6.1:

  1. open ARDUINO_INSTALLATION/hardware/arduino/sam/boards.txt and add the -fpermissive flag, so that the two lines with "extra_flags" read:

    arduino_due_x_dbg.build.extra_flags=-fpermissive -D__SAM3X8E__ -mthumb {build.usb_flags}

    and

    arduino_due_x.build.extra_flags=-fpermissive -D__SAM3X8E__ -mthumb {build.usb_flags}
  2. open ARDUINO_INSTALLATION/libraries/StandardCplusplus/unwind-cxx.h. Make the lines 175-183 a comment and add the line

    const _Unwind_Exception_Class __gxx_exception_class = "GNUCC++\0";

Honestly I have no idea what I did there (my c++ knowledge is limited). So this might be a very bad workaround.

AppliedEM commented 6 years ago

Having the same error with the ESP-12. Has anyone found a workaround that doesn't involve compiling with -fpermissive?

mike-matera commented 6 years ago

This project is dead. I have a replacement you can install using the Arduino Library Manager:

https://github.com/mike-matera/ArduinoSTL

maniacbug commented 1 year ago

Fixed now in 41b4465634e34fce8e010386bd80f9a371c6b311. Running great on my Due