开发者

C++ Declspec align

Hi am new to Visual C++, Could Someone please explain what ConfParams() declared in a structure does

__declspec(align(BYTE)) struct ConfParams
{
    BOOL m_timeout;
    DOUBLE m_c开发者_运维问答aution;
    ConfParams();      
}


Could Someone please explain what ConfParams() declared in a structure does

It's a constructor declaration.

In C++ other than default accessibility level struct and class are equivalent. struct by default has public members, class by default has private members.


I'm not clear why your subject references __declspec but if that's what you want to know about see here.

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

"Use __declspec(align(#)) to precisely control the alignment of user-defined data (for example, static allocations or automatic data in a function)"

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜