edward0429 / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

HardwareSerial is always linked, even if it's not used. #625

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Suggested fix from Michael Smith:

Looking at the code at GitHub, the call to serialEventRun in main.cpp will 
always pull in HardwareSerial.  

If you change the prototype for serialEventRun in HardwareSerial.h to:

extern void serialEventRun(void) __attribute__((weak));

then Blink goes back to the expected size.

This will require a change in main.cpp as well; 

        for (;;) {
                loop();
        if (serialEventRun)
                    serialEventRun();
        }

as the address of serialEventRun will be zero if it's not linked.

A more comprehensive solution would be to use a linker set for the loop 
callouts; I actually composed a longer reply describing that approach before 
realising that just weakref'ing serialEventRun should DTRT.

Original issue reported on code.google.com by dmel...@gmail.com on 5 Sep 2011 at 11:30

GoogleCodeExporter commented 9 years ago
This was fixed as part of issue 626.

Original comment by dmel...@gmail.com on 8 Sep 2011 at 8:31