Search code examples
c++visual-studio-2010syntaxmemory-alignmentdeclspec

__declspec(align) for multiple declarations


Sorry for the very simple question, couldn't find a googleable answer.

Is this declaration syntax:

__declspec(align(16)) float rF[4];
__declspec(align(16)) float gF[4];
__declspec(align(16)) float bF[4];

Equivalent to this:

__declspec(align(16)) float rF[4], gF[4], bF[4];

Or will only the first variable be aligned in the latter syntax?

If it matters, these are local variables inside a global method.


Solution

  • Yes. A __declspec is part of the storage class and applies to all declarators in the declaration.