wolfssl/wolfcrypt/types.h: don't define HAVE_EMPTY_AGGREGATES when defined(__cplusplus) (fixes #8478).

This commit is contained in:
Daniel Pouzzner
2025-02-20 16:49:48 -06:00
parent 41b4ac5599
commit 8aa2799aeb

View File

@ -150,9 +150,17 @@ decouple library dependencies with standard string, memory and so on.
/* The C standards don't define empty aggregates, but gcc and clang do.
* We need to accommodate them for one of the same reasons C++ does --
* conditionally empty aggregates, e.g. in hash.h.
*
* Nonetheless, in C++, empty aggregates wind up with size 1. If we use
* the [0] construct and the header is compiled by clang++, it warns
* "struct has size 0 in C, size 1 in C++ [-Wextern-c-compat]", despite
* the extern "C" wrapper. We sidestep this warning by recognizing
* here that C++ doesn't support truly empty aggregates. LLVM, for its part,
* deprecates compilation of C code as C++ using clang++.
*/
#if !defined(WOLF_C89) && defined(__GNUC__) && \
!defined(__STRICT_ANSI__) && \
!defined(__cplusplus) && \
defined(HAVE_ANONYMOUS_INLINE_AGGREGATES)
#define HAVE_EMPTY_AGGREGATES 1
#endif