46 lines
1.5 KiB
C
46 lines
1.5 KiB
C
#pragma once
|
|
|
|
#ifdef _WIN32
|
|
# define DRANG_DLL_EXPORT __declspec(dllexport)
|
|
# define DRANG_DLL_IMPORT __declspec(dllimport)
|
|
#elif defined(__linux__)
|
|
# define DRANG_DLL_EXPORT __attribute__((visibility("default")))
|
|
# define DRANG_DLL_IMPORT __attribute__((visibility("default")))
|
|
#else
|
|
# error "Unknown platform, please implement shared library export/import macros"
|
|
#endif
|
|
|
|
#if !DRANG_PLATFORM_STATIC
|
|
# if DRANG_PLATFORM_EXPORT
|
|
# define DRANG_PLATFORM_API DRANG_DLL_EXPORT
|
|
# else
|
|
# define DRANG_PLATFORM_API DRANG_DLL_IMPORT
|
|
# endif
|
|
#else
|
|
# define DRANG_PLATFORM_API
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
# define DRANG_BEGIN_DECLS extern "C" {
|
|
# define DRANG_END_DECLS }
|
|
#else
|
|
# define DRANG_BEGIN_DECLS
|
|
# define DRANG_END_DECLS
|
|
#endif
|
|
|
|
#if defined(__GNUC__) || defined(__clang__)
|
|
# define DRANG_PRINTF_ATTR(fmt_idx, arg_idx) __attribute__((format(printf, fmt_idx, arg_idx)))
|
|
# define DRANG_VPRINTF_ATTR(fmt_idx) __attribute__((format(printf, fmt_idx, 0)))
|
|
# define DRANG_ALLOC_SIZE_COUNT_ATTR(count, idx) __attribute__((alloc_size(idx, count)))
|
|
# define DRANG_ALLOC_SIZE_ATTR(idx) __attribute__((alloc_size(idx)))
|
|
# define DRANG_ALLOC_ALIGN_ATTR(idx) __attribute__((alloc_align(idx)))
|
|
# define DRANG_MALLOC_ATTR __attribute__((malloc))
|
|
|
|
#else
|
|
# define DRANG_PRINTF_ATTR(fmt_idx, arg_idx)
|
|
# define DRANG_VPRINTF_ATTR(fmt_idx)
|
|
# define DRANG_ALLOC_SIZE_COUNT_ATTR(idx, count)
|
|
# define DRANG_ALLOC_SIZE_ATTR(idx)
|
|
# define DRANG_ALLOC_ALIGN_ATTR(idx)
|
|
# define DRANG_MALLOC_ATTR
|
|
#endif
|