[Top][All Lists]

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

Re: [avr-gcc-list] C Preprocessor question

From: Dave Hylands
Subject: Re: [avr-gcc-list] C Preprocessor question
Date: Sun, 11 Sep 2005 08:11:04 -0700

Hi Richard,

> Another possibility to play with:
> #define mymacro (foo, somenumber) \
> struct {Fifo fifo; uint8_t buf[somenumber]} foo;\
> const uint8_t  *foo##ptr = (uint8_t*)&foo;

const uint8_t *foo;
uint8_t const *foo;

both create a pointer to a constant uint8_t. You can modify foo (i.e.
foo++ is legal) but you can't modify what foo points at (i.e. *foo =
'x'; wouldn't work).

uint8_t * const foo = something;

creates a constant pointer. You can't modify the pointer itself, but
you're free to modify what the pointer points at. foo++ is illegal,
but *foo = 'x'; is legal.

You can combine the two to create a constant pointer to a constant object.

Dave Hylands
Vancouver, BC, Canada

reply via email to

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