compiler-public.hxx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /** Compiler deficiency workarounds for libpqxx clients.
  2. *
  3. * Copyright (c) 2000-2019, Jeroen T. Vermeulen.
  4. *
  5. * See COPYING for copyright license. If you did not receive a file called
  6. * COPYING with this source code, please notify the distributor of this mistake,
  7. * or contact the author.
  8. */
  9. #ifndef PQXX_H_COMPILER_PUBLIC
  10. #define PQXX_H_COMPILER_PUBLIC
  11. // Workarounds & definitions that need to be included even in library's headers
  12. #include "pqxx/config-public-compiler.h"
  13. // Some compilers, Visual Studio in particular, don't seem to support the
  14. // standard's ISO-646 keywords out of the box.
  15. #include <ciso646>
  16. #if defined(__GNUC__) && defined(PQXX_HAVE_GCC_CONST)
  17. /// Declare function without effects and without reading anything but its args.
  18. #define PQXX_CONST __attribute__ ((const))
  19. #else
  20. #define PQXX_CONST
  21. #endif
  22. #if defined(PQXX_HAVE_DEPRECATED)
  23. /// Mark an item as deprecated.
  24. #define PQXX_DEPRECATED [[deprecated]]
  25. #elif defined(__GNUC__) && defined(PQXX_HAVE_GCC_DEPRECATED)
  26. #define PQXX_DEPRECATED __attribute__ ((deprecated))
  27. #else
  28. #define PQXX_DEPRECATED
  29. #endif
  30. #if defined(__GNUC__) && defined(PQXX_HAVE_GCC_PURE)
  31. /// Declare function "pure": no side effects, only reads globals and its args.
  32. #define PQXX_PURE __attribute__ ((pure))
  33. #else
  34. #define PQXX_PURE
  35. #endif
  36. // Workarounds for Windows
  37. #ifdef _WIN32
  38. /* For now, export DLL symbols if _DLL is defined. This is done automatically
  39. * by the compiler when linking to the dynamic version of the runtime library,
  40. * according to "gzh"
  41. */
  42. #if !defined(PQXX_LIBEXPORT) && defined(PQXX_SHARED)
  43. #define PQXX_LIBEXPORT __declspec(dllimport)
  44. #endif // !PQXX_LIBEXPORT && PQXX_SHARED
  45. // Workarounds for Microsoft Visual C++
  46. #ifdef _MSC_VER
  47. // Suppress vtables on abstract classes.
  48. #define PQXX_NOVTABLE __declspec(novtable)
  49. // Automatically link with the appropriate libpq (static or dynamic, debug or
  50. // release). The default is to use the release DLL. Define PQXX_PQ_STATIC to
  51. // link to a static version of libpq, and _DEBUG to link to a debug version.
  52. // The two may be combined.
  53. #if defined(PQXX_AUTOLINK)
  54. #if defined(PQXX_PQ_STATIC)
  55. #ifdef _DEBUG
  56. #pragma comment(lib, "libpqd")
  57. #else
  58. #pragma comment(lib, "libpq")
  59. #endif
  60. #else
  61. #ifdef _DEBUG
  62. #pragma comment(lib, "libpqddll")
  63. #else
  64. #pragma comment(lib, "libpqdll")
  65. #endif
  66. #endif
  67. #endif
  68. // If we're not compiling libpqxx itself, automatically link with the
  69. // appropriate libpqxx library. To link with the libpqxx DLL, define
  70. // PQXX_SHARED; the default is to link with the static library. A static link
  71. // is the recommended practice.
  72. //
  73. // The preprocessor macro PQXX_INTERNAL is used to detect whether we
  74. // are compiling the libpqxx library itself. When you compile the library
  75. // yourself using your own project file, make sure to include this macro.
  76. #if defined(PQXX_AUTOLINK) && !defined(PQXX_INTERNAL)
  77. #ifdef PQXX_SHARED
  78. #ifdef _DEBUG
  79. #pragma comment(lib, "libpqxxD")
  80. #else
  81. #pragma comment(lib, "libpqxx")
  82. #endif
  83. #else // !PQXX_SHARED
  84. #ifdef _DEBUG
  85. #pragma comment(lib, "libpqxx_staticD")
  86. #else
  87. #pragma comment(lib, "libpqxx_static")
  88. #endif
  89. #endif
  90. #endif
  91. #endif // _MSC_VER
  92. #endif // _WIN32
  93. #ifndef PQXX_LIBEXPORT
  94. #define PQXX_LIBEXPORT
  95. #endif
  96. #ifndef PQXX_PRIVATE
  97. #define PQXX_PRIVATE
  98. #endif
  99. #ifndef PQXX_NOVTABLE
  100. #define PQXX_NOVTABLE
  101. #endif
  102. #endif