mike-matera / ArduinoSTL

An STL and iostream implementation based on uClibc++ that supports my CS-11M class.
GNU General Public License v3.0
325 stars 80 forks source link

multiple definition of `std::nothrow' #84

Open jfjlaros opened 2 years ago

jfjlaros commented 2 years ago

When compiling the following sketch,

#include <ArduinoSTL.h>

void setup() {}
void loop() {}

this error is raised:

arduino-cli compile --fqbn arduino:avr:pro --warnings all --output-dir build \
    --build-property compiler.cpp.extra_flags="-pedantic"
new.cpp.o (symbol from plugin): In function `operator new(unsigned int)':
(.text+0x0): multiple definition of `std::nothrow'
/tmp/arduino-sketch-DAE3E2C59CB46B47AC6BC234B0EB1886/libraries/ArduinoSTL/new_handler.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status

Commenting out line 22 of src/new_handler.cpp seems to fix the issue, but this perhaps introduces other problems.

My set up:

This issue can be reproduced in the Wokwi simulator.

fabianoriccardi commented 2 years ago

Same here!

Also #79 presents the same issue.

POberauer commented 2 years ago

downgrading to arduino:avr core version 1.8.3 fixed the issue.

POberauer commented 2 years ago

or as @jfjlaros states, remore / comment line 22 in ../ArduinoSTL/src/new_handler.cpp: const std::nothrow_t std::nothrow = { }; since for arduino core v1.8.5, std::nothrow, is already defined in its ../core/arduino/new.cpp file.

rw3iss commented 1 year ago

Was getting the same exact error. If I open the library file ArduinoSTL/src/new_handler.cpp and comment out line 22: // const std::nothrow_t std::nothrow = { }; It will allow my program to compile.

quinn-n commented 1 year ago

I'm getting the same error. The workaround posted by @rw3iss works.

crashback-exe commented 1 year ago

same error here, fix by @rw3iss worked

mabsch commented 1 year ago

same error, @rw3iss 's workaround worked.

zhangyonggang316 commented 1 year ago

you are right ,thanks

odisseano commented 1 year ago

Même erreur ;) Merci @rw3iss

reymalahay commented 12 months ago

hi all,

is there going to be an official fix to this issue? i.e. a fix that does not require downgrading other libraries nor commenting out lines of code.

please advise.

thanks in advance, rey malahay

mw66 commented 10 months ago

Was getting the same exact error. If I open the library file ArduinoSTL/src/new_handler.cpp and comment out line 22: // const std::nothrow_t std::nothrow = { }; It will allow my program to compile.

If this is not needed shall we create a PR to delete it, or guarded in some conditional MACRO?

#ifdef xxx
...
#endif
jfjlaros commented 10 months ago

I have created PR #94 to implement the suggestion made in the first post of this issue.

sjimenez100 commented 5 months ago

Was getting the same exact error. If I open the library file ArduinoSTL/src/new_handler.cpp and comment out line 22: // const std::nothrow_t std::nothrow = { }; It will allow my program to compile.

Yep, that fixed it

Ebola-Chan-bot commented 3 weeks ago

See my fork that should have fixed this.