Skip to content

Commit

Permalink
Make C11 _Static_assert() available if we have it
Browse files Browse the repository at this point in the history
  • Loading branch information
bsdphk committed May 27, 2017
1 parent b4f4e20 commit 6ae8119
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
21 changes: 21 additions & 0 deletions configure.ac
Expand Up @@ -359,6 +359,27 @@ 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.
#
Expand Down
5 changes: 5 additions & 0 deletions include/vdef.h
Expand Up @@ -125,4 +125,9 @@
#define NEEDLESS(s) s
#endif

#ifndef STATIC_ASSERT
# define _Static_assert(a,b)
#endif


#endif /* VDEF_H_INCLUDED */

2 comments on commit 6ae8119

@michbsd
Copy link

@michbsd michbsd commented on 6ae8119 Jul 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to break build on FreeBSD 10.x

Making all in lib
gmake[2]: Entering directory '/root/work/varnish-5.1.2/lib'
Making all in libvarnish
gmake[3]: Entering directory '/root/work/varnish-5.1.2/lib/libvarnish'
CC libvarnish_a-binary_heap.o
CC libvarnish_a-vas.o
CC libvarnish_a-vav.o
CC libvarnish_a-vcli_proto.o
CC libvarnish_a-vcli_serve.o
In file included from vcli_serve.c:45:
../../include/vdef.h:129:1: error: "_Static_assert" redefined
In file included from /usr/include/time.h:44,
from vcli_serve.c:34:
/usr/include/sys/cdefs.h:295:1: error: this is the location of the previous definition
gmake[3]: *** [Makefile:790: libvarnish_a-vcli_serve.o] Error 1
gmake[3]: Leaving directory '/root/work/varnish-5.1.2/lib/libvarnish'
gmake[2]: *** [Makefile:410: all-recursive] Error 1
gmake[2]: Leaving directory '/root/work/varnish-5.1.2/lib'
gmake[1]: *** [Makefile:553: all-recursive] Error 1
gmake[1]: Leaving directory '/root/work/varnish-5.1.2'
gmake: *** [Makefile:439: all] Error 2

@fgsch
Copy link
Member

@fgsch fgsch commented on 6ae8119 Jul 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on this.

Please sign in to comment.