config_dll.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. // config_dll.h - written and placed in public domain by Jeffrey Walton
  2. // the bits that make up this source file are from the
  3. // library's monolithic config.h.
  4. /// \file config_dll.h
  5. /// \brief Library configuration file
  6. /// \details <tt>config_dll.h</tt> provides defines for shared objects and
  7. /// dynamic libraries. Generally speaking the macros are used to export
  8. /// classes and template classes from the Win32 dynamic link library.
  9. /// When not building the Win32 dynamic link library they are mostly an extern
  10. /// template declaration.
  11. /// \details In practice they are a furball coughed up by a cat and then peed
  12. /// on by a dog. They are awful to get just right because of inconsistent
  13. /// compiler support for extern templates, manual instantiation and the FIPS DLL.
  14. /// \details <tt>config.h</tt> was split into components in May 2019 to better
  15. /// integrate with Autoconf and its feature tests. The splitting occurred so
  16. /// users could continue to include <tt>config.h</tt> while allowing Autoconf
  17. /// to write new <tt>config_asm.h</tt> and new <tt>config_cxx.h</tt> using
  18. /// its feature tests.
  19. /// \note You should include <tt>config.h</tt> rather than <tt>config_dll.h</tt>
  20. /// directly.
  21. /// \sa <A HREF="https://github.com/weidai11/cryptopp/issues/835">Issue 835,
  22. /// Make config.h more autoconf friendly</A>,
  23. /// <A HREF="https://www.cryptopp.com/wiki/Configure.sh">Configure.sh script</A>,
  24. /// <A HREF="https://www.cryptopp.com/wiki/Visual_Studio">Visual Studio</A>,
  25. /// and <A HREF="https://www.cryptopp.com/wiki/FIPS_DLL">FIPS DLL</A>
  26. /// on the Crypto++ wiki
  27. /// \since Crypto++ 8.3
  28. #ifndef CRYPTOPP_CONFIG_DLL_H
  29. #define CRYPTOPP_CONFIG_DLL_H
  30. #include "config_os.h"
  31. #if defined(CRYPTOPP_DOXYGEN_PROCESSING)
  32. /// \brief Win32 define for dynamic link libraries
  33. /// \details CRYPTOPP_IMPORTS is set in the Visual Studio project files.
  34. /// When the macro is set, <tt>CRYPTOPP_DLL</tt> is defined to
  35. /// <tt>__declspec(dllimport)</tt>.
  36. /// \details This macro has no effect on Unix &amp; Linux.
  37. /// \sa <A HREF="https://www.cryptopp.com/wiki/Visual_Studio">Visual Studio</A>,
  38. /// and <A HREF="https://www.cryptopp.com/wiki/FIPS_DLL">FIPS DLL</A>
  39. /// on the Crypto++ wiki
  40. #define CRYPTOPP_IMPORTS ...
  41. /// \brief Win32 define for dynamic link libraries
  42. /// \details CRYPTOPP_EXPORTS is set in the Visual Studio project files.
  43. /// When the macro is set, <tt>CRYPTOPP_DLL</tt> is defined to
  44. /// <tt>__declspec(dllexport)</tt>.
  45. /// \details This macro has no effect on Unix &amp; Linux.
  46. /// \sa <A HREF="https://www.cryptopp.com/wiki/Visual_Studio">Visual Studio</A>,
  47. /// and <A HREF="https://www.cryptopp.com/wiki/FIPS_DLL">FIPS DLL</A>
  48. /// on the Crypto++ wiki
  49. #define CRYPTOPP_EXPORTS ...
  50. /// \brief Win32 define for dynamic link libraries
  51. /// \details CRYPTOPP_IS_DLL is set in the Visual Studio project files.
  52. /// \sa <A HREF="https://www.cryptopp.com/wiki/Visual_Studio">Visual Studio</A>,
  53. /// and <A HREF="https://www.cryptopp.com/wiki/FIPS_DLL">FIPS DLL</A>
  54. /// on the Crypto++ wiki
  55. #define CRYPTOPP_IS_DLL
  56. /// \brief Instantiate templates in a dynamic library
  57. /// \details CRYPTOPP_DLL_TEMPLATE_CLASS decoration should be used
  58. /// for classes intended to be exported from dynamic link libraries.
  59. /// \details This macro is primarily used on Win32, but sees some
  60. /// action on Unix &amp; Linux due to the source file <tt>dll.cpp</tt>.
  61. /// \sa <A HREF="https://www.cryptopp.com/wiki/Visual_Studio">Visual Studio</A>,
  62. /// and <A HREF="https://www.cryptopp.com/wiki/FIPS_DLL">FIPS DLL</A>
  63. /// on the Crypto++ wiki
  64. #define CRYPTOPP_DLL_TEMPLATE_CLASS ...
  65. /// \brief Instantiate templates in a dynamic library
  66. /// \details CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS decoration should be used
  67. /// for template classes intended to be exported from dynamic link libraries.
  68. /// \details This macro is primarily used on Win32, but sees some
  69. /// action on Unix &amp; Linux due to the source file <tt>dll.cpp</tt>.
  70. /// \sa <A HREF="https://www.cryptopp.com/wiki/Visual_Studio">Visual Studio</A>,
  71. /// and <A HREF="https://www.cryptopp.com/wiki/FIPS_DLL">FIPS DLL</A>
  72. /// on the Crypto++ wiki
  73. #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS ...
  74. /// \brief Instantiate templates in a dynamic library
  75. /// \details CRYPTOPP_STATIC_TEMPLATE_CLASS decoration should be used
  76. /// for template classes intended to be exported from dynamic link libraries.
  77. /// \details This macro is primarily used on Win32, but sees some
  78. /// action on Unix &amp; Linux due to the source file <tt>dll.cpp</tt>.
  79. /// \sa <A HREF="https://www.cryptopp.com/wiki/Visual_Studio">Visual Studio</A>,
  80. /// and <A HREF="https://www.cryptopp.com/wiki/FIPS_DLL">FIPS DLL</A>
  81. /// on the Crypto++ wiki
  82. #define CRYPTOPP_STATIC_TEMPLATE_CLASS ...
  83. /// \brief Instantiate templates in a dynamic library
  84. /// \details CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS decoration should be used
  85. /// for template classes intended to be exported from dynamic link libraries.
  86. /// \details This macro is primarily used on Win32, but sees some
  87. /// action on Unix &amp; Linux due to the source file <tt>dll.cpp</tt>.
  88. /// \sa <A HREF="https://www.cryptopp.com/wiki/Visual_Studio">Visual Studio</A>,
  89. /// and <A HREF="https://www.cryptopp.com/wiki/FIPS_DLL">FIPS DLL</A>
  90. /// on the Crypto++ wiki
  91. #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS ...
  92. /// \brief Override for internal linkage
  93. /// \details CRYPTOPP_TABLE can be used to override internal linkage
  94. /// on tables with the <tt>const</tt> qualifier. According to C++ rules
  95. /// a declaration with <tt>const</tt> qualifier is internal linkage.
  96. /// \note The name CRYPTOPP_TABLE was chosen because it is often used to
  97. /// export a table, like AES or SHA constants. The name avoids collisions
  98. /// with the DLL gear macros, like CRYPTOPP_EXPORTS and CRYPTOPP_EXTERN.
  99. #define CRYPTOPP_TABLE extern
  100. /// \brief Win32 calling convention
  101. /// \details CRYPTOPP_API sets the calling convention on Win32.
  102. /// On Win32 CRYPTOPP_API is <tt>__cedcl</tt>. On Unix &amp; Linux
  103. /// CRYPTOPP_API is defined to nothing.
  104. /// \sa <A HREF="https://www.cryptopp.com/wiki/Visual_Studio">Visual Studio</A>
  105. /// on the Crypto++ wiki
  106. #define CRYPTOPP_API ...
  107. #else // CRYPTOPP_DOXYGEN_PROCESSING
  108. #if defined(CRYPTOPP_WIN32_AVAILABLE)
  109. #if defined(CRYPTOPP_EXPORTS)
  110. # define CRYPTOPP_IS_DLL
  111. # define CRYPTOPP_DLL __declspec(dllexport)
  112. #elif defined(CRYPTOPP_IMPORTS)
  113. # define CRYPTOPP_IS_DLL
  114. # define CRYPTOPP_DLL __declspec(dllimport)
  115. #else
  116. # define CRYPTOPP_DLL
  117. #endif
  118. // C++ makes const internal linkage
  119. #define CRYPTOPP_TABLE extern
  120. #define CRYPTOPP_API __cdecl
  121. #else // not CRYPTOPP_WIN32_AVAILABLE
  122. // C++ makes const internal linkage
  123. #define CRYPTOPP_TABLE extern
  124. #define CRYPTOPP_DLL
  125. #define CRYPTOPP_API
  126. #endif // CRYPTOPP_WIN32_AVAILABLE
  127. #if defined(__MWERKS__)
  128. # define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL
  129. #elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
  130. # define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
  131. #else
  132. # define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL
  133. #endif
  134. #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_IMPORTS)
  135. # define CRYPTOPP_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL
  136. #else
  137. # define CRYPTOPP_DLL_TEMPLATE_CLASS CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS
  138. #endif
  139. #if defined(__MWERKS__)
  140. # define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern class
  141. #elif defined(__BORLANDC__) || defined(__SUNPRO_CC)
  142. # define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class
  143. #else
  144. # define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern template class
  145. #endif
  146. #if defined(CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES) && !defined(CRYPTOPP_EXPORTS)
  147. # define CRYPTOPP_STATIC_TEMPLATE_CLASS template class
  148. #else
  149. # define CRYPTOPP_STATIC_TEMPLATE_CLASS CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS
  150. #endif
  151. #endif // CRYPTOPP_DOXYGEN_PROCESSING
  152. #endif // CRYPTOPP_CONFIG_DLL_H