Project

General

Profile

Bug #1178 » 0028-Autotools-Check-if-var-arg-can-be-const.patch

S3_2, S3_1 - Marko Lindqvist, 12/07/2024 10:56 PM

View differences:

common/featured_text.c
const struct ft_color ftc_client = FT_COLOR("#EF7F00", NULL);
const struct ft_color ftc_editor = FT_COLOR("#0000FF", NULL);
const struct ft_color ftc_command = FT_COLOR("#006400", NULL);
const struct ft_color ftc_changed = FT_COLOR("#FF0000", NULL);
VAR_ARG_CONST struct ft_color ftc_changed = FT_COLOR("#FF0000", NULL);
const struct ft_color ftc_server_prompt = FT_COLOR("#FF0000", "#BEBEBE");
const struct ft_color ftc_player_lost = FT_COLOR("#FFFFFF", "#000000");
const struct ft_color ftc_game_start = FT_COLOR("#00FF00", "#115511");
common/featured_text.h
extern const struct ft_color ftc_client;
extern const struct ft_color ftc_editor;
extern const struct ft_color ftc_command;
extern const struct ft_color ftc_changed;
extern VAR_ARG_CONST struct ft_color ftc_changed;
extern const struct ft_color ftc_server_prompt;
extern const struct ft_color ftc_player_lost;
extern const struct ft_color ftc_game_start;
configure.ac
CXXFLAGS="$EXTRA_DEBUG_CXXFLAGS $CXXFLAGS"
LDFLAGS="$EXTRA_DEBUG_LDFLAGS $LDFLAGS"
dnl Check this when -Werror is already set, if we're going to set it
dnl Check these when -Werror is already set, if we're going to set it
FC_VALUE_AFTER_EXIT
FC_CONST_VAR_ARG
dnl Rebuild 'configure' whenever fc_version changes, if maintainer mode enabled.
AC_SUBST([CONFIGURE_DEPENDENCIES], ["$CONFIGURE_DEPENDENCIES \$(top_srcdir)/fc_version"])
gen_headers/freeciv_config.h.in
/* Returning a value is expected even after exit() call */
#undef FREECIV_RETURN_VALUE_AFTER_EXIT
/* Var arg cannot be const */
#undef FREECIV_NO_CONST_VAR_ARG
/* locale.h available */
#undef FREECIV_HAVE_LOCALE_H
m4/tcc.m4
AC_DEFINE([INIT_BRACE_END], [], [End of C99 structure initializer])
fi
])
# Are const var arg parameters supported?
#
AC_DEFUN([FC_CONST_VAR_ARG],
[
AC_CACHE_CHECK([can var arg be a const],
[ac_cv_const_var_arg],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
void var_arg_func(...);]],
[[const char *param = NULL;
var_arg_func(param);
return 0;
]])],
[ac_cv_const_var_arg=yes], [ac_cv_const_var_arg=no])])
if test "x${ac_cv_const_var_arg}" != "xyes" ; then
AC_DEFINE([FREECIV_NO_CONST_VAR_ARG], [1], [[Var arg cannot be const]])
fi
])
utility/support.h
#define RETURN_VALUE_AFTER_EXIT(_val_)
#endif
#ifdef FREECIV_NO_CONST_VAR_ARG
#define VAR_ARG_CONST
#else
#define VAR_ARG_CONST const
#endif
int fc_strcasecmp(const char *str0, const char *str1);
int fc_strncasecmp(const char *str0, const char *str1, size_t n);
int fc_strncasequotecmp(const char *str0, const char *str1, size_t n);
(2-2/2)