Inline C Macro Problem

I came across this in embedded hardware using C.

#define EnterPWDN(clkcon) (  (void (*)(int))0xc0080e0 ) (clkcon) 

I have no idea how this function macro works. I understand what clkconis the parameter to the EnterPWDN function, but what happens after that?

+5
source share
3 answers

It sends the address to a 0xc0080e0pointer to a function that receives intand returns void, and calls this function, passing it clkconas a parameter.

Highlighted:

typedef void (func_ptr*)(int);
func_ptr func = (func_ptr)0xc0080e0;
func(clkcon);

(If you haven't come across function pointers, you might want to grab a good introduction to C and read about this.)

+8
source

void, int . 0xc0080e0.

(void (*)(int))

. void. , , , int , . - , , , "clkcon".

+5

Goz sbi, , -:

(0xc0080e0) , , . int clkcon.

+3

All Articles