tuklib_common.h revision 207753
1207753Smm/////////////////////////////////////////////////////////////////////////////// 2207753Smm// 3207753Smm/// \file tuklib_common.h 4207753Smm/// \brief Common definitions for tuklib modules 5207753Smm// 6207753Smm// Author: Lasse Collin 7207753Smm// 8207753Smm// This file has been put into the public domain. 9207753Smm// You can do whatever you want with this file. 10207753Smm// 11207753Smm/////////////////////////////////////////////////////////////////////////////// 12207753Smm 13207753Smm#ifndef TUKLIB_COMMON_H 14207753Smm#define TUKLIB_COMMON_H 15207753Smm 16207753Smm// The config file may be replaced by a package-specific file. 17207753Smm// It should include at least stddef.h, inttypes.h, and limits.h. 18207753Smm#include "tuklib_config.h" 19207753Smm 20207753Smm// TUKLIB_SYMBOL_PREFIX is prefixed to all symbols exported by 21207753Smm// the tuklib modules. If you use a tuklib module in a library, 22207753Smm// you should use TUKLIB_SYMBOL_PREFIX to make sure that there 23207753Smm// are no symbol conflicts in case someone links your library 24207753Smm// into application that also uses the same tuklib module. 25207753Smm#ifndef TUKLIB_SYMBOL_PREFIX 26207753Smm# define TUKLIB_SYMBOL_PREFIX 27207753Smm#endif 28207753Smm 29207753Smm#define TUKLIB_CAT_X(a, b) a ## b 30207753Smm#define TUKLIB_CAT(a, b) TUKLIB_CAT_X(a, b) 31207753Smm 32207753Smm#ifndef TUKLIB_SYMBOL 33207753Smm# define TUKLIB_SYMBOL(sym) TUKLIB_CAT(TUKLIB_SYMBOL_PREFIX, sym) 34207753Smm#endif 35207753Smm 36207753Smm#ifndef TUKLIB_DECLS_BEGIN 37207753Smm# ifdef __cplusplus 38207753Smm# define TUKLIB_DECLS_BEGIN extern "C" { 39207753Smm# else 40207753Smm# define TUKLIB_DECLS_BEGIN 41207753Smm# endif 42207753Smm#endif 43207753Smm 44207753Smm#ifndef TUKLIB_DECLS_END 45207753Smm# ifdef __cplusplus 46207753Smm# define TUKLIB_DECLS_END } 47207753Smm# else 48207753Smm# define TUKLIB_DECLS_END 49207753Smm# endif 50207753Smm#endif 51207753Smm 52207753Smm#if defined(__GNUC__) && defined(__GNUC_MINOR__) 53207753Smm# define TUKLIB_GNUC_REQ(major, minor) \ 54207753Smm ((__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)) \ 55207753Smm || __GNUC__ > (major)) 56207753Smm#else 57207753Smm# define TUKLIB_GNUC_REQ(major, minor) 0 58207753Smm#endif 59207753Smm 60207753Smm#if TUKLIB_GNUC_REQ(2, 5) 61207753Smm# define tuklib_attr_noreturn __attribute__((__noreturn__)) 62207753Smm#else 63207753Smm# define tuklib_attr_noreturn 64207753Smm#endif 65207753Smm 66207753Smm#if (defined(_WIN32) && !defined(__CYGWIN__)) \ 67207753Smm || defined(__OS2__) || defined(__MSDOS__) 68207753Smm# define TUKLIB_DOSLIKE 1 69207753Smm#endif 70207753Smm 71207753Smm#endif 72