Pages: [1]   Go Down
Author Topic: Pre-instances of objects in core libraries.  (Read 610 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Sr. Member
****
Karma: 3
Posts: 325
KC4MM
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'd like to see some internal changes to the core libraries (hardwareserial in particular) to allow the programmer to opt out of the preinstantiation of objects.

This could be done in such a way as to not break existing code or documentation by, for example, the use of a statement like:

#define NOHARDWARESERIAL_PREINSTANCE or something like that.

In this case if the #define was present no allocation would be made for buffers and no interrupts would be enabled unless the user specifically created the object -- i.e.

hardwareserial Serial(1); // where the "1" is the Uart to use.

Without the #define things would be as they are now.

This would be especially useful when coding for the Mega which has 4 serial ports. As it is now if even one of them is used buffers are allocated for all four whether or not they are all used. I know it can be done because I've done it. Unfortunately my code has been specifically tailored to 9th bit addressing protocol so has a great deal of code that would not be of general applicability.


« Last Edit: February 26, 2010, 04:16:24 am by RoyK » Logged

Pages: [1]   Go Up
Jump to: