avr-gcc-list
[Top][All Lists]
Advanced

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

[avr-gcc-list] Re: issues with struct and volatile


From: David Brown
Subject: [avr-gcc-list] Re: issues with struct and volatile
Date: Fri, 24 Jul 2009 16:41:02 +0200
User-agent: Thunderbird 2.0.0.22 (Windows/20090605)

Bob Paddock wrote:
On Fri, Jul 24, 2009 at 3:59 AM, David Brown<address@hidden> wrote:

The principle is right, the details are wrong.  You want:

       uint8_t * volatile tx_tail;

These things are so very easy to get wrong that I always use typedefs:

       typedef uint8_t * pUint8_t;
       volatile pUint8_t tx_tail;

That way there is no room for confusion or error.


There is always the 'cdecl' program that does
 English <--> C/C++ declarations translations.

ftp://sunsite.unc.edu/pub/Linux/devel/lang/c/cdecl-2.5.tar.gz
ftp://ftp.delorie.com/pub/djgpp/current/v2apps/cdecl25b.zip
ftp://ftp.delorie.com/pub/djgpp/current/v2apps/cdecl25s.zip

cdecl> explain volatile *x
declare x as pointer to volatile int

cdecl> explain int volatile *x
declare x as volatile pointer to int

Maybe cdecl could be included in WinAVR?

From testing here it doesn't look like cdecl is entirely reliable. But even it were, it is hardly a good idea to write code declarations that are so convoluted that you need extra utilities to interpret them. It is a much better idea to write clear and unambiguous code in the first place - that's what typedefs give you.





reply via email to

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