读书人

volatile会修饰数组么

发布时间: 2012-08-31 12:55:03 作者: rapoo

volatile能修饰数组么
如我定义一个数组DWORD tex[10];我想告诉编译器,其中的每个元素都是易变的,如何 用volatile来修饰?
volatile DWORD tex[10]和DWORD volatile tex[10]都是错的,貌似这样修饰的是数组名...求大神解释。
不胜感激..

[解决办法]
CV-qualifiers 修饰的是数组的元素 而不是数组本身。
c99标准如下:
If the specification of an array type includes any type qualifiers, the element type is soqualified,
not the array type.

c++标准如下:
A compound type (3.9.2) is not cv-qualified by the cv-qualifiers (if any) of the types from which it is compounded.Any cv-qualifiers applied to an array type affect the array element type, not the array type

读书人网 >C++

热点推荐