gcc: Microsoft Windows Function Attributes

1 
1 6.31.17 Microsoft Windows Function Attributes
1 ---------------------------------------------
1 
1 The following attributes are available on Microsoft Windows and Symbian
1 OS targets.
1 
1 'dllexport'
1      On Microsoft Windows targets and Symbian OS targets the 'dllexport'
1      attribute causes the compiler to provide a global pointer to a
1      pointer in a DLL, so that it can be referenced with the 'dllimport'
1      attribute.  On Microsoft Windows targets, the pointer name is
1      formed by combining '_imp__' and the function or variable name.
1 
1      You can use '__declspec(dllexport)' as a synonym for '__attribute__
1      ((dllexport))' for compatibility with other compilers.
1 
1      On systems that support the 'visibility' attribute, this attribute
1      also implies "default" visibility.  It is an error to explicitly
1      specify any other visibility.
1 
1      GCC's default behavior is to emit all inline functions with the
1      'dllexport' attribute.  Since this can cause object file-size
1      bloat, you can use '-fno-keep-inline-dllexport', which tells GCC to
1      ignore the attribute for inlined functions unless the
1      '-fkeep-inline-functions' flag is used instead.
1 
1      The attribute is ignored for undefined symbols.
1 
1      When applied to C++ classes, the attribute marks defined
1      non-inlined member functions and static data members as exports.
1      Static consts initialized in-class are not marked unless they are
1      also defined out-of-class.
1 
1      For Microsoft Windows targets there are alternative methods for
1      including the symbol in the DLL's export table such as using a
1      '.def' file with an 'EXPORTS' section or, with GNU ld, using the
1      '--export-all' linker flag.
1 
1 'dllimport'
1      On Microsoft Windows and Symbian OS targets, the 'dllimport'
1      attribute causes the compiler to reference a function or variable
1      via a global pointer to a pointer that is set up by the DLL
1      exporting the symbol.  The attribute implies 'extern'.  On
1      Microsoft Windows targets, the pointer name is formed by combining
1      '_imp__' and the function or variable name.
1 
1      You can use '__declspec(dllimport)' as a synonym for '__attribute__
1      ((dllimport))' for compatibility with other compilers.
1 
1      On systems that support the 'visibility' attribute, this attribute
1      also implies "default" visibility.  It is an error to explicitly
1      specify any other visibility.
1 
1      Currently, the attribute is ignored for inlined functions.  If the
1      attribute is applied to a symbol _definition_, an error is
1      reported.  If a symbol previously declared 'dllimport' is later
1      defined, the attribute is ignored in subsequent references, and a
1      warning is emitted.  The attribute is also overridden by a
1      subsequent declaration as 'dllexport'.
1 
1      When applied to C++ classes, the attribute marks non-inlined member
1      functions and static data members as imports.  However, the
1      attribute is ignored for virtual methods to allow creation of
1      vtables using thunks.
1 
1      On the SH Symbian OS target the 'dllimport' attribute also has
1      another affect--it can cause the vtable and run-time type
1      information for a class to be exported.  This happens when the
1      class has a dllimported constructor or a non-inline, non-pure
1      virtual function and, for either of those two conditions, the class
1      also has an inline constructor or destructor and has a key function
1      that is defined in the current translation unit.
1 
1      For Microsoft Windows targets the use of the 'dllimport' attribute
1      on functions is not necessary, but provides a small performance
1      benefit by eliminating a thunk in the DLL.  The use of the
1      'dllimport' attribute on imported variables can be avoided by
1      passing the '--enable-auto-import' switch to the GNU linker.  As
1      with functions, using the attribute for a variable eliminates a
1      thunk in the DLL.
1 
1      One drawback to using this attribute is that a pointer to a
1      _variable_ marked as 'dllimport' cannot be used as a constant
1      address.  However, a pointer to a _function_ with the 'dllimport'
1      attribute can be used as a constant initializer; in this case, the
1      address of a stub function in the import lib is referenced.  On
1      Microsoft Windows targets, the attribute can be disabled for
1      functions by setting the '-mnop-fun-dllimport' flag.
1