build: enable -fms-extensions

This eases incorporating fields from/"subclassing" another struct.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2022-04-04 14:28:30 +02:00
parent 5b4f4e626f
commit 3f115705d3
2 changed files with 34 additions and 0 deletions

View file

@ -330,7 +330,21 @@ LDFLAGS="$LDFLAGS -g"
AM_CONDITIONAL([DEV_BUILD], [test "$enable_dev_build" = "yes"])
dnl -fms-extensions causes clang to have a built-in __wchar_t on OpenBSD,
dnl which just straight up breaks compiling any code.
dnl (2022-04-04 / OpenBSD 7 / clang 11.1.0)
AH_VERBATIM([OpenBSD], [
#ifdef __OpenBSD__
#define __wchar_t __wchar_t_ignore
#include <stdint.h>
#undef __wchar_t
#endif
])
dnl always want these CFLAGS
AC_C_FLAG([-fms-extensions], [
AC_MSG_ERROR([$CC does not support unnamed struct fields (-fms-extensions)])
])
AC_C_FLAG([-fno-omit-frame-pointer])
AC_C_FLAG([-funwind-tables])
AC_C_FLAG([-Wall])

View file

@ -897,6 +897,26 @@ necessary replacements.
| u_long | unsigned long |
+-----------+--------------------------+
FRR also uses unnamed struct fields, enabled with ``-fms-extensions`` (cf.
https://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html). The following two
patterns can/should be used where contextually appropriate:
.. code-block:: c
struct outer {
struct inner;
};
.. code-block:: c
struct outer {
union {
struct inner;
struct inner inner_name;
};
};
.. _style-exceptions:
Exceptions