Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Finally, really, actually, starting off with C

2009-01-07 by Dave Hylands

Hi David,

>> All their examples have main as returning an int.
>> Returning a value from main, in a microcontroller is nonsensical, isn't it?
>> Where would it return that to?
>> Why would I want to spend four bytes of RAM on that?
>
> You can declare main like this instead:
>
> void main( void )
> {
>   ....
> }
>
> If you compile your code using the -ffreestanding option, then the
> compiler won't complain that main doesn't return an int.

I see that -ffreestanding turns off the builtin functions (i.e.
-ffreestanding implies -fnobuiltin). I tried this combination:

-ffreestanding -fbuiltin

and this does in fact turn the builtin functions back on (at least
printf of a simple string becomes puts).

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.