double casting in c

Viewed 4347

I have gone over this code and I have noticed this casting that looks weird

oldidt = (unsigned long long *)(*(unsigned long*)(oldidtr+1));  

To me it looks like the first cast is affecting the +1 so it will move 4 bytes (a pointer), and the second cast is for the result being an unsigned long long *. And the star in the outer shell on the inner cast is an "access this memory" star.

  • Is that right?
  • Why bother if the original definition was a pointer, and we're casting to another pointer, the +1 will still be a 4 byte jump.
  • What would happen if I write instead oldidt = *(oldidt+1);? (Assuming the compiler doesn't complain, and gives out and exec)

The declaration of oldidt was:

static unsigned long long *oldidt;  

I'm calling the casts "first" and "second" according to invocation (left is the second).

1 Answers
Related