Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple definition of `std::nothrow' #84

Open
jfjlaros opened this issue Aug 6, 2022 · 13 comments · May be fixed by #94
Open

multiple definition of `std::nothrow' #84

jfjlaros opened this issue Aug 6, 2022 · 13 comments · May be fixed by #94

Comments

@jfjlaros
Copy link

jfjlaros commented Aug 6, 2022

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:

  • arduino-cli Version: 0.25.1 Commit: 436f0bb9 Date: 2022-07-25T15:01:55Z
  • ArduinoSTL version 1.3.3
  • arduino:avr core version 1.8.5

This issue can be reproduced in the Wokwi simulator.

@fabianoriccardi
Copy link

fabianoriccardi commented Aug 21, 2022

Same here!

Also #79 presents the same issue.

@POberauer
Copy link

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

@POberauer
Copy link

POberauer commented Oct 11, 2022

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
Copy link

rw3iss commented Dec 5, 2022

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
Copy link

quinn-n commented Dec 29, 2022

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

@crashback-exe
Copy link

same error here, fix by @rw3iss worked

@mabsch
Copy link

mabsch commented Feb 15, 2023

same error, @rw3iss 's workaround worked.

@zhangyonggang316
Copy link

you are right ,thanks

@odisseano
Copy link

Même erreur ;) Merci @rw3iss

@reymalahay
Copy link

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
Copy link

mw66 commented Jan 20, 2024

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
Copy link
Author

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

jfjlaros added a commit to jfjlaros/ArduinoSTL that referenced this issue Jan 20, 2024
@jfjlaros jfjlaros linked a pull request Jan 21, 2024 that will close this issue
@sjimenez100
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.