[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] avr-gcc printf optimisation ?
From: |
Anton James Erasmus |
Subject: |
Re: [avr-gcc-list] avr-gcc printf optimisation ? |
Date: |
Wed, 17 Dec 2008 07:58:57 +0200 |
Hi,
I have been using my own printf in stead of the printf of
avr-libc. It is based on some public domain code, which was
modified to handle the format string in flash. Since it has
been working fine, I have not switched to the avr-libc
version. I am not sure when this optimisation actually
appeared in gcc, since I seldom use printf("Some
text\r\n").
I can rename the function, but if one uses printf, then gcc
warns one when the parameters does not match the format
string. I was just wondering whether the avr-libc printf
has the same problem, and whether this optimisation has
some sort of workaround. Using a different function seems
to be the workaround. Are there any other functions that
gcc replaces with different functions based on the
arguments ?
Can one get avr-gcc to replace the standard printf with an
integer only printf automatically based on the arguments ?
Regards
Anton Erasmus
On Tue, 16 Dec 2008 13:34:26 -0700
"Weddington, Eric" <address@hidden> wrote:
>
>
>> -----Original Message-----
>> From:
>>
>address@hidden
>>
>[mailto:address@hidden
>> org] On Behalf Of Anton Erasmus
>> Sent: Tuesday, December 16, 2008 1:25 PM
>> To: address@hidden
>> Subject: [avr-gcc-list] avr-gcc printf optimisation ?
>>
>> Hi,
>>
>> I notice that gcc replaces printf with puts if the
>argument
>> is a simple string
>> which ends in "\r\n". Is there way one can disable this
>> optimisation ? I use a
>> macro which replaces printf(<format string>, ...) with
>> printf(PSTR(<format string>), ...).
>> i.e. puts the format string in flash. Unfortunately when
>
>> printf is replaced with puts, the format
>> string ends up in RAM in stead of in flash.
>>
>
>Hi Anton,
>
>Aren't you suppose to be using printf_P() when the format
>string is in flash? Like so?:
>printf_P(PSTR(<format string>, ...);
>
>Does the printf_P function get optimized the same way as
>printf?
- [avr-gcc-list] define const char, Wynand Weyers, 2008/12/15
- RE: [avr-gcc-list] define const char, Schwichtenberg, Knut, 2008/12/15
- [avr-gcc-list] avr-gcc printf optimisation ?, Anton Erasmus, 2008/12/16
- RE: [avr-gcc-list] avr-gcc printf optimisation ?, Weddington, Eric, 2008/12/16
- RE: [avr-gcc-list] avr-gcc printf optimisation ?, Weddington, Eric, 2008/12/16
- Re: [avr-gcc-list] avr-gcc printf optimisation ?,
Anton James Erasmus <=
- Re: [avr-gcc-list] avr-gcc printf optimisation ?, Colin D Bennett, 2008/12/17
- Re: [avr-gcc-list] avr-gcc printf optimisation ?, Joerg Wunsch, 2008/12/17
- Re: [avr-gcc-list] avr-gcc printf optimisation ?, Pink Boy, 2008/12/17
- RE: [avr-gcc-list] avr-gcc printf optimisation ?, Weddington, Eric, 2008/12/17
Re: [avr-gcc-list] avr-gcc printf optimisation ?, Joerg Wunsch, 2008/12/17