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