'Dereference syntax when accessing a struct element in C

The code demo below works but I'm not sure it's syntactically correct.

For example, should this

X = *((QWORD*)(pRegCtx->X));

be replaced with

X = *(QWORD*)(pRegCtx->X);

Plus code looks odd using a QWORD cast

RegisterContext RegCtx = { (QWORD)&X };

Without the (QWORD) cast, the linux c compiler reports:

warning: initialization of ‘long unsigned int’ from ‘QWORD *’ {aka ‘long unsigned int *’} makes integer from pointer without a cast [-Wint-conversion]

Any tips on how make it conform better to the C89 standard?

https://www.onlinegdb.com/0pBta5XO2

#include <stdio.h>
#include <stdint.h>

typedef         uint64_t QWORD;
typedef         uint32_t DWORD;
typedef         uint16_t WORD;
typedef         uint8_t  BYTE;

typedef struct  RegisterContext
{
          QWORD X;
} RegisterContext, *PREGISTERCONTEXT;


void MyFun(PREGISTERCONTEXT pRegCtx)
{
     QWORD X = 0;
     X = *((QWORD*)(pRegCtx->X));
     X += 42;
     *((QWORD*)(pRegCtx->X)) = X;
 } 

int main(void)
{    
         QWORD X = 0;
         RegisterContext RegCtx = { (QWORD)&X };
   
         MyFun(&RegCtx);
         
         // Answer to the Ultimate Question of Life, the Universe, and Everything
         printf("X=%lu\n",X);

    return 0;
}
c


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source