mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
lib/zt_common: add STATIC_ASSERT macro
Add `STATIC_ASSERT` macro that uses `_Static_assert` if available (was introduced with gcc 4.6, see https://gcc.gnu.org/wiki/C11Status). For example, this could be used for the verification of structure sizes at compile time. Acked-by: Jan Höppner <hoeppner@linux.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
971970989b
commit
bac3f93772
@@ -22,6 +22,13 @@
|
||||
# define UNUSED(x) x
|
||||
#endif
|
||||
|
||||
#ifdef STATIC_ASSERT
|
||||
#elif defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ >= 5)
|
||||
# define STATIC_ASSERT(test) _Static_assert((test), "(" #test ") failed");
|
||||
#else
|
||||
# define STATIC_ASSERT(test)
|
||||
#endif
|
||||
|
||||
#define RELEASE_STRING STRINGIFY (S390_TOOLS_RELEASE)
|
||||
#define TOOLS_LIBDIR STRINGIFY (S390_TOOLS_LIBDIR)
|
||||
#define TOOLS_SYSCONFDIR STRINGIFY (S390_TOOLS_SYSCONFDIR)
|
||||
|
||||
Reference in New Issue
Block a user