由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 如果volatile只修饰结构体中的某些成员
相关主题
请教一个C语言的面试题sizeof()的问题
关于const和volatile修饰变量或指针的问题是不是题出错了?
c++ typedef 一问大家帮忙看看是什么问题
how to initialize this struct.intel icc hash_map 求救!
为啥有人喜欢把_s结尾的结构typedef成_t结尾的,有讲究么?STL感觉实在太变态了
about typedef关于typedef的一个问题
如何使用这个template?sgi stl 源代码一问
Why the number is not exact in C++请教函数 INIT 怎么能free memory
相关话题的讨论汇总
话题: volatile话题: int话题: abc话题: 处理话题: 体中
进入Programming版参与讨论
1 (共1页)
h*****n
发帖数: 209
1
如果volatile
typedef struct
{
volatile int a;
int b;
int c;
}AAA;
ABC abc;
那么compiler只对abc.a是按volatile处理,对abc.b和abc.c仍然按非volatile处理,
对吗?
m*******l
发帖数: 12782
2
y

【在 h*****n 的大作中提到】
: 如果volatile
: typedef struct
: {
: volatile int a;
: int b;
: int c;
: }AAA;
: ABC abc;
: 那么compiler只对abc.a是按volatile处理,对abc.b和abc.c仍然按非volatile处理,
: 对吗?

d****n
发帖数: 1241
3
理论上是,但是编译器在处理结构体的volatile field的时候,
经常会出错,比如说,并不是所有对于abc.a的读操作,都会有
一个对应的memory load. 尤其是当优化级别高的时候,
出错的可能性更大。

【在 h*****n 的大作中提到】
: 如果volatile
: typedef struct
: {
: volatile int a;
: int b;
: int c;
: }AAA;
: ABC abc;
: 那么compiler只对abc.a是按volatile处理,对abc.b和abc.c仍然按非volatile处理,
: 对吗?

1 (共1页)
进入Programming版参与讨论
相关主题
请教函数 INIT 怎么能free memory为啥有人喜欢把_s结尾的结构typedef成_t结尾的,有讲究么?
difference between FILE and struct FILEabout typedef
请问可以这样定义struct吗?如何使用这个template?
c++ template question:Why the number is not exact in C++
请教一个C语言的面试题sizeof()的问题
关于const和volatile修饰变量或指针的问题是不是题出错了?
c++ typedef 一问大家帮忙看看是什么问题
how to initialize this struct.intel icc hash_map 求救!
相关话题的讨论汇总
话题: volatile话题: int话题: abc话题: 处理话题: 体中