dbus-macros.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
  2. /* dbus-macros.h generic macros
  3. *
  4. * Copyright (C) 2002 Red Hat Inc.
  5. *
  6. * Licensed under the Academic Free License version 2.1
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. */
  23. #if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION)
  24. #error "Only <dbus/dbus.h> can be included directly, this file may disappear or change contents."
  25. #endif
  26. #ifndef DBUS_MACROS_H
  27. #define DBUS_MACROS_H
  28. #ifdef __cplusplus
  29. # define DBUS_BEGIN_DECLS extern "C" {
  30. # define DBUS_END_DECLS }
  31. #else
  32. # define DBUS_BEGIN_DECLS
  33. # define DBUS_END_DECLS
  34. #endif
  35. #ifndef TRUE
  36. # define TRUE 1
  37. #endif
  38. #ifndef FALSE
  39. # define FALSE 0
  40. #endif
  41. #ifndef NULL
  42. # ifdef __cplusplus
  43. # define NULL (0L)
  44. # else /* !__cplusplus */
  45. # define NULL ((void*) 0)
  46. # endif /* !__cplusplus */
  47. #endif
  48. #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
  49. # define DBUS_DEPRECATED __attribute__ ((__deprecated__))
  50. #elif defined(_MSC_VER) && (_MSC_VER >= 1300)
  51. # define DBUS_DEPRECATED __declspec(deprecated)
  52. #else
  53. # define DBUS_DEPRECATED
  54. #endif
  55. #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
  56. # define _DBUS_GNUC_EXTENSION __extension__
  57. #else
  58. # define _DBUS_GNUC_EXTENSION
  59. #endif
  60. #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
  61. #define _DBUS_GNUC_PRINTF( format_idx, arg_idx ) \
  62. __attribute__((__format__ (__printf__, format_idx, arg_idx)))
  63. #define _DBUS_GNUC_NORETURN \
  64. __attribute__((__noreturn__))
  65. #else /* !__GNUC__ */
  66. #define _DBUS_GNUC_PRINTF( format_idx, arg_idx )
  67. #define _DBUS_GNUC_NORETURN
  68. #endif /* !__GNUC__ */
  69. #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
  70. #define DBUS_MALLOC __attribute__((__malloc__))
  71. #else
  72. #define DBUS_MALLOC
  73. #endif
  74. #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
  75. #define DBUS_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
  76. #define DBUS_ALLOC_SIZE2(x,y) __attribute__((__alloc_size__(x,y)))
  77. #else
  78. #define DBUS_ALLOC_SIZE(x)
  79. #define DBUS_ALLOC_SIZE2(x,y)
  80. #endif
  81. /** @def _DBUS_GNUC_PRINTF
  82. * used to tell gcc about printf format strings
  83. */
  84. /** @def _DBUS_GNUC_NORETURN
  85. * used to tell gcc about functions that never return, such as _dbus_abort()
  86. */
  87. /* Normally docs are in .c files, but there isn't a .c file for this. */
  88. /**
  89. * @defgroup DBusMacros Utility macros
  90. * @ingroup DBus
  91. * @brief #TRUE, #FALSE, #NULL, and so on
  92. *
  93. * Utility macros.
  94. *
  95. * @{
  96. */
  97. /**
  98. * @def DBUS_BEGIN_DECLS
  99. *
  100. * Macro used prior to declaring functions in the D-Bus header
  101. * files. Expands to "extern "C"" when using a C++ compiler,
  102. * and expands to nothing when using a C compiler.
  103. *
  104. * Please don't use this in your own code, consider it
  105. * D-Bus internal.
  106. */
  107. /**
  108. * @def DBUS_END_DECLS
  109. *
  110. * Macro used after declaring functions in the D-Bus header
  111. * files. Expands to "}" when using a C++ compiler,
  112. * and expands to nothing when using a C compiler.
  113. *
  114. * Please don't use this in your own code, consider it
  115. * D-Bus internal.
  116. */
  117. /**
  118. * @def TRUE
  119. *
  120. * Expands to "1"
  121. */
  122. /**
  123. * @def FALSE
  124. *
  125. * Expands to "0"
  126. */
  127. /**
  128. * @def NULL
  129. *
  130. * A null pointer, defined appropriately for C or C++.
  131. */
  132. /**
  133. * @def DBUS_DEPRECATED
  134. *
  135. * Tells the compiler to warn about a function or type if it's used.
  136. * Code marked in this way should also be enclosed in
  137. * @code
  138. * #ifndef DBUS_DISABLE_DEPRECATED
  139. * deprecated stuff here
  140. * #endif
  141. * @endcode
  142. *
  143. * Please don't use this in your own code, consider it
  144. * D-Bus internal.
  145. */
  146. /**
  147. * @def _DBUS_GNUC_EXTENSION
  148. *
  149. * Tells gcc not to warn about extensions to the C standard in the
  150. * following expression, even if compiling with -pedantic. Do not use
  151. * this macro in your own code; please consider it to be internal to libdbus.
  152. */
  153. /*
  154. * @def DBUS_EXPORT
  155. *
  156. * Declare the following symbol as public. This is currently a noop on
  157. * platforms other than Windows.
  158. */
  159. #if defined(_WIN32)
  160. # if defined(DBUS_STATIC_BUILD)
  161. # define DBUS_EXPORT
  162. # elif defined(dbus_1_EXPORTS)
  163. # define DBUS_EXPORT __declspec(dllexport)
  164. # else
  165. # define DBUS_EXPORT __declspec(dllimport)
  166. # endif
  167. #else
  168. #define DBUS_EXPORT
  169. #endif
  170. /** @} */
  171. #endif /* DBUS_MACROS_H */