i don't understand the syntax ((typedef *) address value)

hi Everybody,
i copy and paste a line of code bellow as an example:

"#define USB (( USB_TypeDef *) USB_BASE)"

( suppose #define USB_BASE 0x0C000 )

i don't understand the "(( USB_TypeDef *) USB_BASE)"?
why the *, the pointer operator, is placed with type inside parenthesis?

thanks,
Ras

Parents
  • Hi Ras,
    The code ( USB_TypeDef *) is a typecast first of all. And it tells the compiler that the following variable or immediate value after this typecast is an address and that memory address is going to hold a data which is of type "USB_TypeDef".

    As an example I would take your code itself that is "#defineUSB_BASE 0x0C000". So here the code "#define USB (( USB_TypeDef *) USB_BASE)" tells the compiler that the value 0x0C000 is an address and it is holding a data with the data type of USB_TypeDef.

    Please reply if anything is not clear.
Reply
  • Hi Ras,
    The code ( USB_TypeDef *) is a typecast first of all. And it tells the compiler that the following variable or immediate value after this typecast is an address and that memory address is going to hold a data which is of type "USB_TypeDef".

    As an example I would take your code itself that is "#defineUSB_BASE 0x0C000". So here the code "#define USB (( USB_TypeDef *) USB_BASE)" tells the compiler that the value 0x0C000 is an address and it is holding a data with the data type of USB_TypeDef.

    Please reply if anything is not clear.
Children
No data