api.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License, version 2.0, as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is also distributed with certain software (including
  9. * but not limited to OpenSSL) that is licensed under separate terms,
  10. * as designated in a particular file or component or in included license
  11. * documentation. The authors of MySQL hereby grant you an
  12. * additional permission to link the program and your derivative works
  13. * with the separately licensed software that they have included with
  14. * MySQL.
  15. *
  16. * Without limiting anything contained in the foregoing, this file,
  17. * which is part of MySQL Connector/C++, is also subject to the
  18. * Universal FOSS Exception, version 1.0, a copy of which can be found at
  19. * http://oss.oracle.com/licenses/universal-foss-exception.
  20. *
  21. * This program is distributed in the hope that it will be useful, but
  22. * WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  24. * See the GNU General Public License, version 2.0, for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software Foundation, Inc.,
  28. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  29. */
  30. #ifndef MYSQLX_COMMON_API_H
  31. #define MYSQLX_COMMON_API_H
  32. /*
  33. Macros for declaring public API
  34. ===============================
  35. API function declarations should be decorated with PUBLIC_API prefix. API
  36. classes should have PUBLIC_API marker between the "class" keyword and
  37. the class name.
  38. See: https://gcc.gnu.org/wiki/Visibility
  39. TODO: Use better name than PUBLIC_API - not all public API classes should
  40. be decorated with these declarations but only these whose implementation
  41. is inside the library (so, not the ones which are implemented in headers).
  42. */
  43. #if defined _MSC_VER
  44. #define DLL_EXPORT __declspec(dllexport)
  45. #define DLL_IMPORT __declspec(dllimport)
  46. #define DLL_LOCAL
  47. #elif __GNUC__ >= 4
  48. #define DLL_EXPORT __attribute__ ((visibility ("default")))
  49. #define DLL_IMPORT
  50. #define DLL_LOCAL __attribute__ ((visibility ("hidden")))
  51. #elif defined __SUNPRO_CC || defined __SUNPRO_C
  52. #define DLL_EXPORT __global
  53. #define DLL_IMPORT __global
  54. #define DLL_LOCAL __hidden
  55. #else
  56. #define DLL_EXPORT
  57. #define DLL_IMPORT
  58. #define DLL_LOCAL
  59. #endif
  60. #if defined CONCPP_BUILD_SHARED
  61. #define PUBLIC_API DLL_EXPORT
  62. #define INTERNAL DLL_LOCAL
  63. #elif defined CONCPP_BUILD_STATIC
  64. #define PUBLIC_API
  65. #define INTERNAL
  66. #elif !defined STATIC_CONCPP
  67. #define PUBLIC_API DLL_IMPORT
  68. #define INTERNAL
  69. #else
  70. #define PUBLIC_API
  71. #define INTERNAL
  72. #endif
  73. #endif