Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Omit all new and delete implementation when AVR core provides it #8

Conversation

matthijskooijman
Copy link

@matthijskooijman matthijskooijman commented Jan 10, 2022

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 #2 (comment) 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 does not seem to be a complete and proper fix for the conflict
between uclibc++ new/delete and the ones defined by the AVR core, since
it only fixes conflicts in the header files, but source files might
still produce linker errors.

So better revert it and stay closer to upstream uclibc++ sources.

This reverts commit 84b4a91.
@CLAassistant
Copy link

CLAassistant commented Jan 10, 2022

CLA assistant check
All committers have signed the CLA.

@matthijskooijman
Copy link
Author

W00ps, hit submit too soon. I edited in a proper PR description just now.

@LuanVSO
Copy link
Contributor

LuanVSO commented Jan 10, 2022

Why revert the changes from #2?
It is common/best practice to include internal headers with quotes and external ones with angle brackets.

@matthijskooijman
Copy link
Author

See the commit message:

So better revert it and stay closer to upstream uclibc++ sources.

But keeping it with double quotes also has some logic, as you also argue.

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.
@matthijskooijman
Copy link
Author

I'm closing this PR, and will instead submit to https://github.com/mike-matera/ArduinoSTL which seems to be active again (and has pulled changes from this repo as well).

@aentinger
Copy link
Contributor

Check, I'll sunset this library and point it towards https://github.com/mike-matera/ArduinoSTL .

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

Successfully merging this pull request may close these issues.

4 participants