[英]C++ Declspec align
Hi am new to Visual C++, Could Someone please explain what ConfParams() declared in a structure does 嗨,我是Visual C ++的新手,有人可以解释结构中声明的ConfParams()做什么吗
__declspec(align(BYTE)) struct ConfParams
{
BOOL m_timeout;
DOUBLE m_caution;
ConfParams();
}
Could Someone please explain what ConfParams() declared in a structure does
有人可以解释结构中声明的ConfParams()做什么吗
It's a constructor declaration. 这是一个构造函数声明。
In C++ other than default accessibility level struct
and class
are equivalent. 在C ++中,除默认可访问性级别以外,
struct
和class
是等效的。 struct
by default has public
members, class
by default has private
members. struct
默认具有public
成员, class
默认具有private
成员。
I'm not clear why your subject references __declspec
but if that's what you want to know about see here . 我不清楚您的主题为何引用
__declspec
但是如果您要了解的内容, 请参见此处 。
Member functions have no alignment only the data is affected. 成员函数不对齐,仅影响数据。
google says 谷歌说
http://msdn.microsoft.com/en-US/library/83ythb65%28v=VS.80%29.aspx http://msdn.microsoft.com/en-US/library/83ythb65%28v=VS.80%29.aspx
"Use __declspec(align(#)) to precisely control the alignment of user-defined data (for example, static allocations or automatic data in a function)" “使用__declspec(align(#))来精确控制用户定义数据的对齐方式(例如,函数中的静态分配或自动数据)”
It will make the compiler start every instance on a byte boundary. 这将使编译器在字节边界上启动每个实例。 Without it instances would have been aligned on the machines natural boundary - which would probably be 4 bytes.
没有它,实例将在机器的自然边界上对齐-可能是4个字节。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.