Commit 1a0d149d authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Have I ever mentioned how much I hate the ISO-C people and the

****heads in the gcc&llvm projects who cannot cooperate on
usability features ?

Fixes #2449
parent 919af666
......@@ -368,27 +368,6 @@ AC_CHECK_DECL([SO_ACCEPTFILTER],
]
)
# Check for _Static_assert()
# We dont' want to go all C11 on this, and we have vas.h instead
# of assert.h, so check the brutal way
save_LIBS="${LIBS}"
LIBS=""
AC_CACHE_CHECK([for _Static_assert],
[ac_cv_static_assert],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM([[
_Static_assert(1 == sizeof(char), "didn't work");
]],[[
]])],
[ac_cv_static_assert=yes],
[ac_cv_static_assert=no])
])
if test "$ac_cv_static_assert" = yes; then
AC_DEFINE([STATIC_ASSERT], [1], [Define if _Static_assert is availabel])
fi
LIBS="${save_LIBS}"
# Older Solaris versions define SO_{RCV,SND}TIMEO, but do not
# implement them.
#
......
......@@ -127,8 +127,28 @@
#define NEEDLESS(s) s
#endif
#ifndef STATIC_ASSERT
# define _Static_assert(a,b)
/*
* Most of this nightmare is stolen from FreeBSD's <cdefs.h>
*/
#if defined(_Static_assert)
/* Nothing, somebody already did this for us */
#elif defined(__has_extension) && __has_extension(c_static_assert)
/* Nothing, we should be fine */
#elif (defined(__cplusplus) && __cplusplus >= 201103L) || \
__has_extension(cxx_static_assert)
# define _Static_assert(x, y) static_assert(x, y)
#elif __GNUC_PREREQ__(4,6) && !defined(__cplusplus)
/* Nothing, gcc 4.6 and higher has _Static_assert built-in */
#else
# if defined(__COUNTER__)
# define _Static_assert(x, y) __Static_assert(x, __COUNTER__)
# else
# define _Static_assert(x, y) __Static_assert(x, __LINE__)
# endif
# define __Static_assert(x, y) ___Static_assert(x, y)
# define ___Static_assert(x, y) \
typedef char __assert_ ## y[(x) ? 1 : -1] __unused
#endif
#endif /* VDEF_H_INCLUDED */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment