On FreeBSD it is currently not possible to use the clang builtin
headers to build the base system. The build will fail with the
following error if I don't delete the std* headers from the clang
install directory:
/sources/freebsd-mips/include/stdio.h:72:19: error: redefinition of typedef 'va_list' is a C11 feature [-Werror,-Wtypedef-redefinition] typedef __va_list va_list; ^ /home/alr48/cheri/output/sdk/lib/clang/7.0.0/include/stdarg.h:30:27: note: previous definition is here typedef __builtin_va_list va_list; /sources/freebsd-mips/sys/sys/_stdarg.h:46:11: error: 'va_start' macro redefined [-Werror,-Wmacro-redefined] #define va_start(ap, last) __builtin_va_start((ap), (last)) ^ /home/alr48/cheri/output/sdk/lib/clang/7.0.0/include/stdarg.h:35:9: note: previous definition is here #define va_start(ap, param) __builtin_va_start(ap, param)
FreeBSD includes definitions of va_list, va_copy, etc in the
<machine/stdarg.h> header and some files end up including both that
header and <stdarg.h>.
Only defining the va_* macros if they are not yet defined fixes the
macro redefiniton issue and probably also makes sense for other
operating systems. However, for the va_list typedef I can't think
of a better solution than to also check for _VA_LIST_DECLARED and
define it.