3

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.

Rotem
  • 21,452
  • 6
  • 62
  • 109

1 Answers1

5

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

James McNellis
  • 348,265
  • 75
  • 913
  • 977
  • Why do you guys keep deleting and un-deleting your answers :) – Rotem Jan 07 '13 at 20:59
  • I answered, then David answered with the opposite answer, so I removed mine while I verified that it is indeed correct. I wanted to be sure. – James McNellis Jan 07 '13 at 21:01
  • Thanks! Have you found this mentioned in the docs anywhere or is this purely from experience? – Rotem Jan 07 '13 at 21:04
  • 2
    [The documentation for `__declspec`](http://msdn.microsoft.com/en-us/library/dabb5z75.aspx) begins with "the extended attribute syntax for specifying storage-class information uses the `__declspec` keyword..." and storage class is a property of the declaration, not of an individual declarator (just like `static` applies to the whole declaration, not an individual declarator). My quick test verified that given `__declspec(align(64)) int a, b, c, d, e;`, all five integers are aligned on 64-byte boundaries. – James McNellis Jan 07 '13 at 21:07
  • Thanks again for the comprehensive help. – Rotem Jan 07 '13 at 21:09