avr-chat
[Top][All Lists]
Advanced

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

[avr-chat] My own _P routines don't save data space :-(


From: Rick Mann
Subject: [avr-chat] My own _P routines don't save data space :-(
Date: Wed, 18 Jul 2012 02:25:56 -0700

Following the example of printf_P, I added a couple routines to my own code 
that took string literals. My code reads from program space, and I pass the 
literals using PSTR("foo"). It's my own version, rewritten to avoid compiler 
warnings:

    #define PROG_MEM __attribute__((section(".progmem.workaround")))

    #undef PSTR
    #define PSTR(s) (__extension__({static char const __c[] PROG_MEM = (s); 
&__c[0];}))


when I replace a call like

    printf("Foo\n");

with

    printf_P(PSTR("Foo\n"));

I see a corresponding drop (four bytes, in this case) in my data section size. 
But when I do the same thing with my own routines, I see no change in size. My 
routines are declared like this:

    void lcdPuts(uint8_t pos, const char *p);
    void lcdPuts_P(uint8_t pos, const char *p);

Is there something I'm overlooking?

Thanks,
Rick




reply via email to

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