I was about to suggest the same, but you've beaten me ;-) The story (marginally related): I have developed a couple of similar macros (taking the "object" rather than pointer as a parameter) while playing with the _far variety of pgm_read_xxx. My intention was to merge ELPMs with taking of the "far pointer" via Carlos Lamas' GET_FAR_ADDRESS macro, potentially reducing the code a bit and sparing one register.
To my astonishment, in all but trivial programs such convoluted piece of assembler in fact INCREASED both code size and register usage! In spite of all my efforts, the register allocator saw my chunk of program as an obstacle and allocated more registers than originally for the surrounding operations. So all what my asm spared in code size went to function prologues/epilogues... There are limitations to the method, though, e.g. when using it on array members, so it has to be used with appropriate caution (and documented accordingly). Jan Waclawek ----- Original Message --------------- Subject: Re: [avr-libc-dev] New pgm_read_ptr() macro? From: David Brown <da...@westcontrol.com> >How about a more general solution based on typeof and sizeof? _______________________________________________ AVR-libc-dev mailing list AVR-libc-dev@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-libc-dev