[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] New pgm_read_ptr() macro?
From: |
Dean Camera |
Subject: |
[avr-libc-dev] New pgm_read_ptr() macro? |
Date: |
Tue, 1 Jun 2010 21:34:25 +1000 |
Hi,
I've been pondering the addition of a new "pgm_read_ptr()" macro to
<avr/pgmspace.h> to fill a gap (in my eyes) in the current API. Currently, to
read out pointers stored in PROGMEM space, one has to use pgm_read_word() and
cast the result to the desired pointer. This is bad (IMHO) as it requires
specific knowledge of the exact pointer width on the AVRs, which could in
theory change, and it makes the code a little harder to read.
I'm proposing a simple extra macro be added:
#define pgm_read_ptr( x ) (void*)pgm_read_word( x )
Which would hide this from the user, so they do not have to use the more
ambiguous macros when dealing with progmem pointers. This would also be helpful
as it is implicitly typecast to the correct pointer type when used as a
initialiser, like:
char* FlashPtr = pgm_read_ptr(&FlashPointer);
Without user intervention. Thoughts anyone?
Cheers!
- Dean
- [avr-libc-dev] New pgm_read_ptr() macro?,
Dean Camera <=
- RE: [avr-libc-dev] New pgm_read_ptr() macro?, Weddington, Eric, 2010/06/01
- Re: [avr-libc-dev] New pgm_read_ptr() macro?, David Brown, 2010/06/01
- Re: [avr-libc-dev] New pgm_read_ptr() macro?, Jan Waclawek, 2010/06/01
- Re: [avr-libc-dev] New pgm_read_ptr() macro?, David Brown, 2010/06/03
- RE: [avr-libc-dev] New pgm_read_ptr() macro?, Weddington, Eric, 2010/06/03
- Message not available
- RE: [avr-libc-dev] New pgm_read_ptr() macro?, Weddington, Eric, 2010/06/03
- Re: [avr-libc-dev] New pgm_read_ptr() macro?, David Brown, 2010/06/03
- RE: [avr-libc-dev] New pgm_read_ptr() macro?, Weddington, Eric, 2010/06/03
- RE: [avr-libc-dev] New pgm_read_ptr() macro?, Jan Waclawek, 2010/06/03
- Re: [avr-libc-dev] New pgm_read_ptr() macro?, Dale Whitfield, 2010/06/03