This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

void pointer

Hi,

Any idea what does following do and how ?

((void (code *) (void)) 0) ();

Any help would be great

Parents
  • techven,

    It's still early, so spare me the tirade if I screw this up, but here goes:

    What this snippet of code is probably meant to do (in short form) is reset the processor (or at least jump code execution to address 0 so it can jump to the start of the application).

    Andy's right that this is all standard C, but just start from the 0 (the only value in the statement) and look at the casts. The value is cast to a pointer (in code memory, in this case) to a function returning void and taking no parameters (although the author put in an extra "void" for clarity). After this cast, the function at that location is "called" with the (); which will do what I described above.

Reply
  • techven,

    It's still early, so spare me the tirade if I screw this up, but here goes:

    What this snippet of code is probably meant to do (in short form) is reset the processor (or at least jump code execution to address 0 so it can jump to the start of the application).

    Andy's right that this is all standard C, but just start from the 0 (the only value in the statement) and look at the casts. The value is cast to a pointer (in code memory, in this case) to a function returning void and taking no parameters (although the author put in an extra "void" for clarity). After this cast, the function at that location is "called" with the (); which will do what I described above.

Children