yoshi99
yoshi99

Reputation: 109

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_caution;
    ConfParams();      
}

Upvotes: 2

Views: 1211

Answers (2)

Brian R. Bondy
Brian R. Bondy

Reputation: 347426

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.

Upvotes: 3

pm100
pm100

Reputation: 50190

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.

Upvotes: 1

Related Questions