6.32.8 Microsoft Windows Variable Attributes
You can use these attributes on Microsoft Windows targets. x86 Variable Attributes for additional Windows compatibility attributes available on all x86 targets.
dllimport
dllexport
-
The
dllimport
anddllexport
attributes are described in Microsoft Windows Function Attributes. selectany
-
The
selectany
attribute causes an initialized global variable to have link-once semantics. When multiple definitions of the variable are encountered by the linker, the first is selected and the remainder are discarded. Following usage by the Microsoft compiler, the linker is told not to warn about size or content differences of the multiple definitions.Although the primary usage of this attribute is for POD types, the attribute can also be applied to global C++ objects that are initialized by a constructor. In this case, the static initialization and destruction code for the object is emitted in each translation defining the object, but the calls to the constructor and destructor are protected by a link-once guard variable.
The
selectany
attribute is only available on Microsoft Windows targets. You can use__declspec (selectany)
as a synonym for__attribute__ ((selectany))
for compatibility with other compilers. shared
-
int foo __attribute__((section ("shared"), shared)) = 0; int main() { /* Read and write foo. All running copies see the same value. */ return 0; }
You may only use the
shared
attribute along withsection
attribute with a fully-initialized global definition because of the way linkers work. Seesection
attribute for more information.The
shared
attribute is only available on Microsoft Windows.
Next: MSP430 Variable Attributes, Previous: MeP Variable Attributes, Up: Variable Attributes [Contents][Index]
© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-7.4.0/gcc/Microsoft-Windows-Variable-Attributes.html