I recently came across the below code where macro is defined as below
unsigned char cbuf[10];
#define pbuf() (&cbuf[0])
Can anyone please explain what is being done in the #define
(macro definition) line?
When ever code contains So, the intention of the macro is to give address of first element of cbuf variable (what ever that variable is in current scope, since preprocessor really just does "string replace" without no idea of context). It is a bit redundant, since name of the array is also address of it's first element... In other words, where ever you would use | |||||||||||||
|
pbuf()
is being defined to(&cbuf[0])
... – H2CO3 Nov 2 '12 at 7:41