Project

General

Profile

Feature #692 ยป 0028-Meson-Add-C23-static_assert-support.patch

Marko Lindqvist, 06/15/2024 07:07 PM

View differences:

gen_headers/meson_freeciv_config.h.in
/* Delta protocol enabled */
#mesondefine FREECIV_DELTA_PROTOCOL
/* C23 static assert supported */
#mesondefine FREECIV_C23_STATIC_ASSERT
/* C11 static assert supported */
#mesondefine FREECIV_C11_STATIC_ASSERT
meson.build
pub_conf_data.set('FREECIV_HAVE_LIBZSTD', 1)
endif
if c_compiler.compiles('''
#include <assert.h>
int main(void) { static_assert(1, "1 is not true"); }''',
name: 'c23 Static Assert')
pub_conf_data.set('FREECIV_C23_STATIC_ASSERT', 1)
endif
if c_compiler.compiles('''
#include <assert.h>
int main(void) { _Static_assert(1, "1 is not true"); }''',
utility/log.h
extern "C" {
#endif /* __cplusplus */
#include <assert.h>
#include <stdarg.h>
#include <stdlib.h>
......
#define FC_STATIC_ASSERT(cond, tag) static_assert(cond, #tag)
#endif /* FREECIV_CXX11_STATIC_ASSERT */
#else /* __cplusplus */
#ifdef FREECIV_C11_STATIC_ASSERT
#ifdef FREECIV_C23_STATIC_ASSERT
#define FC_STATIC_ASSERT(cond, tag) static_assert(cond, #tag)
#elif defined(FREECIV_C11_STATIC_ASSERT)
#define FC_STATIC_ASSERT(cond, tag) _Static_assert(cond, #tag)
#endif /* FREECIV_C11_STATIC_ASSERT */
#ifdef FREECIV_STATIC_STRLEN
    (1-1/1)