Does making a struct volatile make all its members volatile?

前端 未结 2 704
渐次进展
渐次进展 2020-11-30 18:32

If I have:

struct whatever {
int data;
};
volatile whatever test;
will test.data be volatile too?

2条回答
  •  春和景丽
    2020-11-30 18:59

    From: http://msdn.microsoft.com/en-us/library/145yc477%28v=vs.80%29.aspx

    To declare the object pointed to by the pointer as const or volatile, use a declaration of the form:

    const char *cpch;
    volatile char *vpch;
    

    To declare the value of the pointer — that is, the actual address stored in the pointer — as const or volatile, use a declaration of the form:

    char * const pchc;
    char * volatile pchv;
    

提交回复
热议问题