What does this macro define?

c, macros

Solution

I think `sram` means "start of RAM".

unsigned char[1]

An array of size 1 of unsigned chars.

unsigned char(*)[1]

A pointer to an array of size 1 of unsigned chars.

(unsigned char (*)[1]) 0

Cast 0 to a pointer to an array of size 1 of unsigned chars.

*((unsigned char (*)[1]) 0)

Read some memory at location 0, and interpret the result as an array of size 1 of unsigned chars.

(*((unsigned char (*)[1]) 0))

Just to avoid 1+5*8+1==42.

#define sram (*((unsigned char (*)[1]) 0))

Define the variable `sram` to the memory starting at location 0, and interpret the result as an array of size 1 of unsigned chars.

Problem

I read this piece of macro(C code) and was confused in decoding it to know what it defines. What does it define? ``` #define sram (*((unsigned char (*)[1]) 0)) ``` -AD

Original source

Related problems