avr-libc-corelib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Avr-libc-corelib] proposed corelib style guide


From: John Myers
Subject: RE: [Avr-libc-corelib] proposed corelib style guide
Date: Wed, 23 Sep 2009 17:57:32 -0700

The code below works even without ever defining the weak function, so
defining the function can be reserved for the user when they need it.


uint8_t i2c_get_address (void) __attribute__ ((weak));

if (i2c_get_address)
        i2c_get_address ();

--John

-----Original Message-----
From: Ron Kreymborg [mailto:address@hidden 
Sent: Wednesday, September 23, 2009 12:51 AM
To: address@hidden
Subject: RE: [Avr-libc-corelib] proposed corelib style guide

> void GetClockFrequency(long crystal);

Of course this should be: long GetClockFrequency(void):
 
> Thinking of call-back, is there some gcc modifier that allows for
> definition
> of a "weak" function? This would allow call-backs to be instanced in
> the
> library as null functions and save the user from creating an instance
> in
> their code just to satisfy the linker when they have no need for it.
> Hmmm.
> Or does that invite problems?

Answering myself, I just built a quick test library and gcc's __attribute__
((weak)) works fine.

My question could be answered by the weak version returning something or
doing something impossible, which the library could use to define an error.
This probably needs more thought...

Ron










reply via email to

[Prev in Thread] Current Thread [Next in Thread]