[Top][All Lists]

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

Re: [avr-gcc-list] Want to place __func__ in program memory

From: Wim Lewis
Subject: Re: [avr-gcc-list] Want to place __func__ in program memory
Date: Sun, 29 Apr 2012 20:41:16 -0700
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:11.0) Gecko/20120327 Thunderbird/11.0.1

On 4/29/12 2:29 PM, Wim Lewis wrote:
> On 4/29/12 11:46 AM, Alex Iljin wrote:
>> In the same way I define DEBUG_ASSERT_PROGMEM macro.
>> It is OK, but I want to use many trace and assert functions, so there
>> is a question.
>> Is there way to place function name in program memory?
>> Maybe there are specific __FUNC_PROGMEM__ marco, or some compiler parameters,
>> which switch __func__ from charecter array to string literal?
> I had thought that __FUNCTION__ and __PRETTY_FUNCTION__ acted like
> string literals and could be used this way, but I just tested and they
> seem to act like __func__.

Poking around in the gcc internals, gcc appears to treat them all the
same; it essentially synthesizes a declaration like

  const char *__func__ = "funcname";

It seems to me that it would be a useful extension to allow gcc to
initialize "char foo[]" from any "char *" expression whose destination
is known at compile time--- looking at digest_init() (in c-typeck.c),
all the information is available in the initializer's tree node, but gcc
isn't willing to winkle out the string_cst from the structure and use
it. I suppose there's probably a good reason not to do this :)

reply via email to

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