Closed barawn closed 7 years ago
I think the attribute is supposed to be on the declaration in the header file, not on the definition in the .c file
It does actually work like this, because wiring.c is what actually contains the object to link to - other object files don't need to know the reference is weak because they're just trying to link to something.
But I changed it to duplicate the way that it's done in HardwareSerial.h/.cpp, although I left off the extern declaration because declaring a function prototype external is completely redundant.
@barawn I realize you had it correct the first time.
Energia.h: extern "C" void enableXtal(void);
wiring.c void attribute((weak)) enableXtal(void);
void enableXtal(void) { ... all the code ... }
I did test the code and realized for the smaller G series chips, the enableXtal() function is being called twice. I'm pretty sure this wasn't the intent. This function is a ifdefed to death.
Ha! That's actually issue #10 . It was mistakenly reintroduced by commit 4732e353440e433477048ef66ef5feccde464b8d .
issue #10 should be fixed again here. I also changed the declaration to match your suggestion, except the extern "C" isn't required because it's already in an extern "C" block, and you really need the attribute (rather than just attribute).
Edit: I see what happened there, markdown confused me by eating the underscores.
…present.