Understanding special syntax, void(* resetFunc) (void) = 0;

I found this in:


void(* resetFunc) (void) = 0;
//declare reset function @ address 0

I don't get a single bit of it. Is this just an alternative one-way method of defining a function? How would that function have looked like in another format?

What does it mean that a function is at address 0?


It's a crude method of doing a software reset. It defines a pointer to a function, and sets that pointer to zero, so when you call the function, you transfer control to the reset vector at address zero.

What is the reset vector? A function?

The reset vector is first thing the processor fetches after a hardware reset to point it to the start of whatever code it is supposed to execute immediately after a hardware reset.

If you want, you can read about it in the processor's datasheet, available from the Atmel website.

And this is totally non portable. Assigning integer 0 to a pointer gets you the null pointer which is not guaranteed to be all-bits-zero.

If you want a way to figure out complex data definitions, like:

double (*(*pf)())[3][4];

take a look at a summary of my Left-Right Rule at: