muwerk/ustd

#include <new.h> vs #include <new>?

SteveEisner opened this issue · 3 comments

I was trying to compile an Arduino app on Teensy 4.0. With Teensy 3.X I've been using ustd by defining __ATMEGA__ and it worked OK.

As far as I can tell, Teensy 4.0 uses an updated Arduino Core that no longer exposes <new.h>
See: https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/new.h for example, that suggests that core moved away from using this file. I guess the Teensy 4 doesn't even bother to try to offer this stub.

As a result, the compile fails with:

In file included from .platformio/lib/ustd/ustd_array.h:31:0,
.platformio/lib/ustd/ustd_platform.h:113:51: fatal error: new.h: No such file or directory

But it does work when I change it to:

#include <new>

Would that be an appropriate update to https://github.com/muwerk/ustd/blob/master/ustd_platform.h#L113 ? Or possibly to expose a new platform #define that controls the behavior?

I've added a new platform define __TEENSY40__, which should use the proper memory allocation routines of the ARM M7 core. Since I don't have the hardware, I would be grateful, if you could check if it now works? If there are no problems, I would publish a new release 0.7.1.

Release 0.7.1 with Teensy 4.0 support is published. Thank You!

Thanks so much for such a fast response!
I use platform.io to include your library, and I'm not seeing 0.7.1 show up there yet - but I did clone master into my project and confirm that it compiles correctly with the new __TEENSY40__. I'll test it on a real board ASAP just to make sure the runtime works correctly but I can't imagine there being any problem.