tuklib_common.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. /// \file tuklib_common.h
  4. /// \brief Common definitions for tuklib modules
  5. //
  6. // Author: Lasse Collin
  7. //
  8. // This file has been put into the public domain.
  9. // You can do whatever you want with this file.
  10. //
  11. ///////////////////////////////////////////////////////////////////////////////
  12. #ifndef TUKLIB_COMMON_H
  13. #define TUKLIB_COMMON_H
  14. // The config file may be replaced by a package-specific file.
  15. // It should include at least stddef.h, stdbool.h, inttypes.h, and limits.h.
  16. #include "tuklib_config.h"
  17. // TUKLIB_SYMBOL_PREFIX is prefixed to all symbols exported by
  18. // the tuklib modules. If you use a tuklib module in a library,
  19. // you should use TUKLIB_SYMBOL_PREFIX to make sure that there
  20. // are no symbol conflicts in case someone links your library
  21. // into application that also uses the same tuklib module.
  22. #ifndef TUKLIB_SYMBOL_PREFIX
  23. # define TUKLIB_SYMBOL_PREFIX
  24. #endif
  25. #define TUKLIB_CAT_X(a, b) a ## b
  26. #define TUKLIB_CAT(a, b) TUKLIB_CAT_X(a, b)
  27. #ifndef TUKLIB_SYMBOL
  28. # define TUKLIB_SYMBOL(sym) TUKLIB_CAT(TUKLIB_SYMBOL_PREFIX, sym)
  29. #endif
  30. #ifndef TUKLIB_DECLS_BEGIN
  31. # ifdef __cplusplus
  32. # define TUKLIB_DECLS_BEGIN extern "C" {
  33. # else
  34. # define TUKLIB_DECLS_BEGIN
  35. # endif
  36. #endif
  37. #ifndef TUKLIB_DECLS_END
  38. # ifdef __cplusplus
  39. # define TUKLIB_DECLS_END }
  40. # else
  41. # define TUKLIB_DECLS_END
  42. # endif
  43. #endif
  44. #if defined(__GNUC__) && defined(__GNUC_MINOR__)
  45. # define TUKLIB_GNUC_REQ(major, minor) \
  46. ((__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)) \
  47. || __GNUC__ > (major))
  48. #else
  49. # define TUKLIB_GNUC_REQ(major, minor) 0
  50. #endif
  51. #if TUKLIB_GNUC_REQ(2, 5)
  52. # define tuklib_attr_noreturn __attribute__((__noreturn__))
  53. #else
  54. # define tuklib_attr_noreturn
  55. #endif
  56. #if (defined(_WIN32) && !defined(__CYGWIN__)) \
  57. || defined(__OS2__) || defined(__MSDOS__)
  58. # define TUKLIB_DOSLIKE 1
  59. #endif
  60. #endif