David, David VanHorn wrote: > Yes.. The world probably will end in 2012, brought about in no small > part by my conversion to C. > > I bought an AVR-LIP kit from Deccan, and am using WINAVR to get going. > > I have a few questions. > > 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? Welcome to GCC! GCC is a "big iron" compiler front end and all programs written for full OS's require a return code for main(). AVR is a custom backend of the compiler so main must be of type int for compatibility reasons. > > Declaring a variable: > Does C (or Winavr) init a declared variable to some defined state > ALWAYS, or do I have to? > I don't mind doing it, and I'm sure that's absolutely safe, but I > don't want to do un-necessary operations. > Would the compiler be smart enough to take out a redundant init of a > variable? (assuming right after declaration) Global and static variables will always be auto-initialized to zero (according to the docs I've read), you'll need to initialize locals yourself if you care about their initial state (which you should). The compiler will not remove an unnecessary init. You are correct, doing it yourself will use up code space. DLC > -- ------------------------------------------------- Dennis Clark TTT Enterprises www.techtoystoday.com -------------------------------------------------
Message
Re: [AVR-Chat] Finally, really, actually, starting off with C
2009-01-07 by dlc
Attachments
- No local attachments were found for this message.