For instance:
#include "usb_generic.h"
void setup() {}
void loop() {}
[victor_pv – Sun Feb 04, 2018 4:28 pm] –
Perhaps leave the instances out of the class files, so the user defines in the sketch if they are going to be used?
That would work, but I want to make this as friendly as possible to the user, and to mimic how the core works. The core defines lots of such convenience instances like Serial, Serial1, etc.
[arpruss – Sun Feb 04, 2018 4:33 pm] –
That would work, but I want to make this as friendly as possible to the user, and to mimic how the core works. The core defines lots of such convenience instances like Serial, Serial1, etc.
I suspect ease-of-use for end-users of Arduino was why C++ was elected for Arduino, but they still argue about it over on Arduino.cc
If you go searching around the Internet, avoid anything that was pre-Arduino 1.5.8 because the 1.5.8 version fundamentally changed much of the back-end methodology. https://www.arduino.cc/en/Main/OldSoftw … ases#1.5.x October 2014
But, it is not a STM32 issue, even the Teensy dudes/dudettes have issues.
Ray
compiler.c.elf.extra_flags="-L{build.variant.path}/ld" -specs=nosys.specs -specs=nano.specs [stevestrong – Sun Feb 04, 2018 5:35 pm] –
You may try to edit the platform.txt by adding the “-specs” compiler directives:
Yeah, that does reduce size.
I still would like to solve the library class instance linking issue. It would be nice if there were some way to define an instance of a class that would only get linked in if the class is referenced. But C++ standards presumably require that if the instance is created, then its constructor is called, and hence at least the constructor needs to get linked in. And then any virtual functions also need to be linked in along with constructor.
Is there a way to split an Arduino library, so depending on which header files you include, only a part of the library gets included?
[arpruss – Sun Feb 04, 2018 5:46 pm] –
…
Is there a way to split an Arduino library, so depending on which header files you include, only a part of the library gets included?
You can put any library into you local sketch folder …. .h and .cpp files become tabs. You reference them in #include “./file.xxx” rather than using the braces <…>
Depending on how you do things, the Arduino auto-prototyping may fail, you may need to do a forward declaration.
Ray
[stevestrong – Sun Feb 04, 2018 5:35 pm] –
…
I use it in my repo, it reduces considerably the code size with no side issues so far.
NOOB warning:
The GCC compiler and associated software tools are remarkably complex… which is why ArduinoIDE keeps this mess hidden from the average user. Please understand, if you deviate from the defaults, you are (in my opinion) on your own for support. For those inquisitive, a list of options is available here: https://gcc.gnu.org/onlinedocs/gcc/Option-Index.html
Ray
[stevestrong – Sun Feb 04, 2018 5:35 pm] –
You may try to edit the platform.txt by adding the “-specs” compiler directives:
compiler.c.elf.extra_flags="-L{build.variant.path}/ld" -specs=nosys.specs -specs=nano.specs
[michael_l – Mon Feb 05, 2018 4:51 pm] –
At least the %f format of printf will not work anymore. But there is a option to include %f, but can’t remember that from the top of my head.


