[Top][All Lists]

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

Re: [avr-gcc-list] Compiler macros and how to define them?

From: Colin Paul Gloster
Subject: Re: [avr-gcc-list] Compiler macros and how to define them?
Date: Mon, 16 Jul 2007 12:59:29 +0200 (CEST)

On Mon, 16 Jul 2007, Alexander Rice wrote:


     My question is: what must I do to ensure that the the variable
     '__clocksource' behaves like a #define statement and the function
     'timer1_clocksource' is inlined?"

Do not use the C preprocessor. Please read books about why 
this is bad.
     "Also, from looking at the math.h library routines I 
have gathered that the
     convention seems to be to use two underscore characters for variables
     defined in header files. Are there any other conventions I should be aware
     of; or better, a coding style guide for header files?"

Identifiers beginning with two underscore characters are 
supposed to be reserved to implementers.
     "[..] By wrapping some functions similar to the
     above in some #if defined (__AVR_ATmega32__) etc. statements to deal with
     specific devices it would seem to be fairly simple, so simple in fact that
     if I got it working nicely I could contribute it back 
to the project."

Please read the book by Kernighan and Pike entitled "The 
Practice of Programming" which contains an example of how to 
do this in C without preprocessing.

Colin Paul Gloster

reply via email to

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