[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] FW: optimalisation level setting from within C-source
Re: [avr-gcc-list] FW: optimalisation level setting from within C-source code....
Tue, 16 Oct 2007 20:46:36 +0200 (MET DST)
"=?iso-8859-2?Q?Ing.Ji=F8=ED_Petr=E1k_-_PERYS?=" <address@hidden> wrote:
> first of all - I am first time writing to avr-gcc list members, and
> - I am only true hobbist of AVR programming..
Please subscribe to the list, you might miss some answers otherwise,
and I had to manually approve your posting.
> Is it possible to set the optimalisation level for some functions
> (or part of source-code) to different level than optimalisation used
> for this project as default?
The only option would be at the file level, i.e. you compile one source
file with -O0, other files with -Os.
However, I would not really recommend you that. Instead, write your
code in an optimization-independent manner, as much as possible. For
exact timing delays, please have a look at the functions in
<avr/delay_basic.h> and their convenience wrappers in <avr/delay.h>.
Note that the latter use floating-point calculations that are meant to
be optimized away at compile time, so they are required to be compiled
with optimization enabled. The functions from <avr/delay_basic.h> are
truely optimzation independent but you have to manually pre-calculate
the cycle counts then.
cheers, J"org .-.-. --... ...-- -.. . DL8DTL
http://www.sax.de/~joerg/ NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)