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

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

[avr-libc-dev] Re: [Avr-libc-corelib] proposed corelib style guide


From: Mike Perks
Subject: [avr-libc-dev] Re: [Avr-libc-corelib] proposed corelib style guide
Date: Tue, 22 Sep 2009 22:07:57 -0500
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

Ruddick,

This is a good start. I agree with most of what you have said except the following:

1. We need to define what to do with functions defined via macros. Macros in the .h file are public by definition and macros in the .c file are private. Macros in c files should probably never be used and substituted with static functions, possibly inlined 2. There are several rules for typedefs in avr-libc. Probably the most consistent with what we already have is a lower case words with underscore and a simple suffix of _t e.g. clock_div_t

The only other question is when to use #defines, enums and const values. The first two are rvalues. A const value is a non-modifiable lvalue and the compiler may reserve storage for it e.g.

   *int const *N* = 100;*
   *int const *p = &N;    // ok*

However most people are probably not going to write this type of code. Defines do not have scope restrictions whereas enums and consts do.

I think we should use the simplest definitions in header files (#defines) and possibly some enums for a grouping of values. Inside an implementation then people should use enums and consts. Again enums for a logical grouping such as a state indicator and consts for individual constants such as a buffer size.

Mike Perks
Oak Micros (oakmicros.com)


reply via email to

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