mirror of
https://github.com/thepigeongenerator/tetris_clone.git
synced 2025-12-17 05:55:46 +01:00
rework attributes.h as atrb.h
This commit is contained in:
59
src/util/atrb.h
Normal file
59
src/util/atrb.h
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
#ifndef ATRB_H
|
||||||
|
#define ATRB_H 1
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#if __has_attribute(__pure__)
|
||||||
|
#define PURE __attribute__((__pure__))
|
||||||
|
#else
|
||||||
|
#define PURE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __has_attribute(__const__)
|
||||||
|
#define CONST __attribute__((__const__))
|
||||||
|
#else
|
||||||
|
#define CONST
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __has_attribute(__noreturn__)
|
||||||
|
#define NORET __attribute__((__noreturn__))
|
||||||
|
#else
|
||||||
|
#define NORET
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __has_attribute(__malloc__)
|
||||||
|
#define MALLOC __attribute__((__malloc__))
|
||||||
|
#else
|
||||||
|
#define MALLOC
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __has_attribute(__used__)
|
||||||
|
#define USED __attribute__((__used__))
|
||||||
|
#else
|
||||||
|
#define USED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __has_attribute(__unused__)
|
||||||
|
#define UNUSED __attribute__((__unused__))
|
||||||
|
#else
|
||||||
|
#define UNUSED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __has_attribute(__deprecated__)
|
||||||
|
#define DEPRECATED __attribute__((__deprecated__))
|
||||||
|
#else
|
||||||
|
#define DEPRECATED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __has_attribute(__format__)
|
||||||
|
#define FORMAT(args) __attribute__((format args))
|
||||||
|
#else
|
||||||
|
#define FORMAT(args)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __has_attribute(__nonnull__)
|
||||||
|
#define NONNULL(args) __attribute__((__nonnull__ args))
|
||||||
|
#else
|
||||||
|
#define NONNULL(args)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
// default attribute definitions (empty)
|
|
||||||
#define atrb_deprecated
|
|
||||||
#define atrb_unused
|
|
||||||
#define atrb_pure
|
|
||||||
#define atrb_const
|
|
||||||
|
|
||||||
// define the attributes where possible
|
|
||||||
#if defined(__GNUC__) || defined(__clang__)
|
|
||||||
|
|
||||||
#if __has_attribute(deprecated)
|
|
||||||
#undef atrb_deprecated
|
|
||||||
#define atrb_deprecated __attribute__((deprecated))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __has_attribute(unused)
|
|
||||||
#undef atrb_unused
|
|
||||||
#define atrb_unused __attribute__((unused))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __has_attribute(pure)
|
|
||||||
#undef atrb_pure
|
|
||||||
#define atrb_pure __attribute__((pure))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __has_attribute(const)
|
|
||||||
#undef atrb_const
|
|
||||||
#define atrb_const __attribute__((const))
|
|
||||||
#endif
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
#undef atrb_depatrb_deprecated
|
|
||||||
#define atrb_deprecated __declspec(deprecated)
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user