[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: Joerg Wunsch
Subject: Re: [avr-gcc-list] Compiler macros and how to define them?
Date: Tue, 17 Jul 2007 07:20:01 +0200 (MET DST)

Alexander Rice <address@hidden> wrote:

> This works, however a look at the .lst file seems to suggest that
> 'clocksource' and the function 'timer1_clocksource' are actually
> defined in the compiled code.

Note that the .lst file is a disassembly listing, which tries to match
the corresponding source code based on its debugging (line number)
information.  This often looks confusing, and you have to look very
carefully in particular when optimization is enabled.

> 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?

1) Enable optimization.  2) Use `static' declarators for everything
that is not needed outside the current compilation unit.

Both are a good idea anyway.

> 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.

As Colin mentioned, this is completely wrong.  Identifiers starting
with two underscores, or with one underscore and an uppercase letter,
or global identifiers starting with one underscore in general are
reserved ``for the implementation'', i.e. for those who write the
compiler and the system library.  This rule exists to give the
implementors a namespace that does not collide with the application
namespace available to the user.  As such, all global identifiers in
system header files obviously have to follow these rules.

> Setting up timers is a common and somewhat laborious task requiring
> repeated reference to the datasheet, it would be nice to have a
> library routine that made things easier.

We used to have that, but it wasn't really practical.  There are so
many options in setting up a timer, and that helper function didn't
cover more than a single assignment statement would cover, so we
eventually removed that.

What you're probably are for is some kind of code generation wizard.
There once have been a few people discussing that idea, and there's
even a wizavrd project (I think on sourceforge.net), but it never
evolved beyond a few initial ideas.

cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)

reply via email to

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