Rockbox mail archiveSubject: Re: Writing code for Rockbox
Re: Writing code for Rockbox
From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 28 Jan 2003 08:41:47 +0100 (CET)
On Tue, 28 Jan 2003 rockbox_at_diffenbach.org wrote:
> What are the sizes of the fundamental types (short, int, long, etc.)?
The "standard" 32-bit ones:
short - 16 bits
int/long - 32 bits
> How are floating point types handled? Is floating point emulated? Roughly,
> how inefficient is it?
We avoid floats like the plague. Everything float needs to be emulated and
thus we get a lot of extra chunks of code in the image the second we start
using floats. IMHO, we have no need for floats.
> Are you writing under the C89 or C99 language Standard?
We only build with gcc, so we've taken the freedom to use some gcc-extensions
but otherwise we're mostly C89-compliant I think.
> but docs/API states that malloc and free are available. I'm a bit confused.
They *could* be available, but they are not. We have decided we don't need
> How much stack (automatic variable) space is available? How much can any
> one function "politely" use?
Default stack size is 0x400 per thread, but it differs slightly. Try the
debug menu to see stack usage stats.
> > Write normal C code. Don't redefine the language. No new types (structs
> > are structs, not typedefs)
> Does this mean that using typedef at all is deprecated? (I find typedef in
> common/*, but not in apps/*.)
Nah, not deprecated, just wisely suggested to keep at a minimum.
> Can I assume that underscores are ok in variable names and in #defines?
> (I've noticed underscores in the code.)
Yes they are. In general, just follow how things are written already and
you'll be fine.
> Also, I don't want to be argumentative, and I apologize if it's a sore
> point, but why the ban on "const"?
If you come up with a good use of const, please use it.
> Finally, I've never written code for embedded or small memory systems, and
> I'm much more of a C++ coder than a C coder. Any tips you can offer on
> either of these points, or any other obvious questions I should be asking?
Yes: have fun! ;-)
-- Daniel Stenberg -- http://rockbox.haxx.se/ -- http://daniel.haxx.se/Received on 2003-01-28