ArduinoSTL icon indicating copy to clipboard operation
ArduinoSTL copied to clipboard

Omit all new and delete implementation when AVR core provides it

Open matthijskooijman opened this issue 3 years ago • 2 comments

This fixes remaining issues with new/delete conflicts between this library and the AVR core by simply omitting all new-related stuff from this library when the AVR core provides it.

For more info, see https://github.com/arduino-libraries/Arduino_AVRSTL/pull/2#issuecomment-1008798285 and the commit message of the main commit of this PR:

Since AVR core 1.8.3, it provides an (incomplete) new header that breaks
compilation of the uclibc++ new/delete .cpp files. Since 1.8.4 it
provides a complete new header, but that also introduces a linker
duplicate symbol issue for std::nothrow.

This commit adds a USING_NEW_FROM_UCLIBC define to our new include file,
which allows detecting which version of the new include is used. That
define is used to completely skip all new/delete code (all new_*.cpp and
del_*.cpp files) when the new header from the AVR-core is used.

This should fix all conflicts, except:
 - On AVR core 1.8.3, new/delete is now incomplete. However, the missing
   functions (array placement new, placement delete, nothrow versions
   and delete with size) are probably not commonly used.
 - If another library *also* offers <new>, then things might break in
   different ways. Again, this is a rare corner case.
 - This no longer provides set_new_handler, which the AVR core declares
   but does not define. However, since the uclibc++ version did not
   actually *use* the handler passed, not defining it is probably
   better.

This PR was previously submitted against Arduino_AVRSTL, but since this repo seems to be a bit more active again and Arduino stopped maintaining their fork, I'm resubmitting this here.

matthijskooijman avatar Jun 29 '22 16:06 matthijskooijman

@mike-matera You have no activities on this repository for 7 months. Do you need help? I desperately want this branch to be merged.

Ebola-Chan-bot avatar Sep 25 '22 07:09 Ebola-Chan-bot

ping @mike-matera

Dexus avatar Dec 18 '22 13:12 Dexus