Use C99 to compile Expat sources under Unix
Expat requires C99 and doesn't compile without the appropriate command line option at least under Solaris as <stdbool.h> is not available without it there. Closes https://github.com/wxWidgets/wxWidgets/pull/1250 Closes #18352.
This commit is contained in:
parent
2dbe91bb00
commit
fbd645b2dd
@ -68,6 +68,7 @@ HOST_SUFFIX = @HOST_SUFFIX@
|
||||
DYLIB_RPATH_INSTALL = @DYLIB_RPATH_INSTALL@
|
||||
DYLIB_RPATH_POSTLINK = @DYLIB_RPATH_POSTLINK@
|
||||
wx_top_builddir = @wx_top_builddir@
|
||||
wxCFLAGS_C99 = @wxCFLAGS_C99@
|
||||
|
||||
### Variables: ###
|
||||
|
||||
@ -211,7 +212,7 @@ WXTIFF_OBJECTS = \
|
||||
wxtiff_tif_zip.o \
|
||||
wxtiff_tif_zstd.o
|
||||
WXEXPAT_CFLAGS = -DNDEBUG -I./src/expat/expat -DHAVE_EXPAT_CONFIG_H \
|
||||
$(____SHARED) $(CPPFLAGS) $(CFLAGS)
|
||||
$(____SHARED) $(wxCFLAGS_C99) $(CPPFLAGS) $(CFLAGS)
|
||||
WXEXPAT_OBJECTS = \
|
||||
wxexpat_xmlparse.o \
|
||||
wxexpat_xmlrole.o \
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
<if cond="FORMAT=='autoconf'">
|
||||
<option name="wxUSE_EXPAT"/>
|
||||
<option name="wxCFLAGS_C99"/>
|
||||
<set var="LIB_EXPAT">
|
||||
<if cond="wxUSE_EXPAT=='builtin'">
|
||||
wxexpat$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@ -31,6 +32,7 @@
|
||||
HAVE_EXPAT_CONFIG_H
|
||||
</define>
|
||||
<cflags-borland>-w-8004 -w-8008 -w-8012 -w-8057 -w-8066</cflags-borland>
|
||||
<cflags cond="FORMAT=='autoconf'">$(wxCFLAGS_C99)</cflags>
|
||||
<sources>
|
||||
src/expat/expat/lib/xmlparse.c
|
||||
src/expat/expat/lib/xmlrole.c
|
||||
|
184
configure
vendored
184
configure
vendored
@ -976,6 +976,7 @@ DIRECTFB_CFLAGS
|
||||
GTK_CONFIG
|
||||
GTK_LIBS
|
||||
GTK_CFLAGS
|
||||
wxCFLAGS_C99
|
||||
subdirs
|
||||
LIBTIFF_LIBS
|
||||
LIBTIFF_CFLAGS
|
||||
@ -23785,6 +23786,189 @@ $as_echo "$as_me: WARNING: system expat library not found, will use built-in ins
|
||||
fi
|
||||
fi
|
||||
if test "$wxUSE_EXPAT" = "builtin" ; then
|
||||
save_CC="$CC"
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5
|
||||
$as_echo_n "checking for $CC option to accept ISO C99... " >&6; }
|
||||
if ${ac_cv_prog_cc_c99+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
ac_cv_prog_cc_c99=no
|
||||
ac_save_CC=$CC
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Check varargs macros. These examples are taken from C99 6.10.3.5.
|
||||
#define debug(...) fprintf (stderr, __VA_ARGS__)
|
||||
#define showlist(...) puts (#__VA_ARGS__)
|
||||
#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
|
||||
static void
|
||||
test_varargs_macros (void)
|
||||
{
|
||||
int x = 1234;
|
||||
int y = 5678;
|
||||
debug ("Flag");
|
||||
debug ("X = %d\n", x);
|
||||
showlist (The first, second, and third items.);
|
||||
report (x>y, "x is %d but y is %d", x, y);
|
||||
}
|
||||
|
||||
// Check long long types.
|
||||
#define BIG64 18446744073709551615ull
|
||||
#define BIG32 4294967295ul
|
||||
#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
|
||||
#if !BIG_OK
|
||||
your preprocessor is broken;
|
||||
#endif
|
||||
#if BIG_OK
|
||||
#else
|
||||
your preprocessor is broken;
|
||||
#endif
|
||||
static long long int bignum = -9223372036854775807LL;
|
||||
static unsigned long long int ubignum = BIG64;
|
||||
|
||||
struct incomplete_array
|
||||
{
|
||||
int datasize;
|
||||
double data[];
|
||||
};
|
||||
|
||||
struct named_init {
|
||||
int number;
|
||||
const wchar_t *name;
|
||||
double average;
|
||||
};
|
||||
|
||||
typedef const char *ccp;
|
||||
|
||||
static inline int
|
||||
test_restrict (ccp restrict text)
|
||||
{
|
||||
// See if C++-style comments work.
|
||||
// Iterate through items via the restricted pointer.
|
||||
// Also check for declarations in for loops.
|
||||
for (unsigned int i = 0; *(text+i) != '\0'; ++i)
|
||||
continue;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check varargs and va_copy.
|
||||
static void
|
||||
test_varargs (const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, format);
|
||||
va_list args_copy;
|
||||
va_copy (args_copy, args);
|
||||
|
||||
const char *str;
|
||||
int number;
|
||||
float fnumber;
|
||||
|
||||
while (*format)
|
||||
{
|
||||
switch (*format++)
|
||||
{
|
||||
case 's': // string
|
||||
str = va_arg (args_copy, const char *);
|
||||
break;
|
||||
case 'd': // int
|
||||
number = va_arg (args_copy, int);
|
||||
break;
|
||||
case 'f': // float
|
||||
fnumber = va_arg (args_copy, double);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
va_end (args_copy);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
// Check bool.
|
||||
_Bool success = false;
|
||||
|
||||
// Check restrict.
|
||||
if (test_restrict ("String literal") == 0)
|
||||
success = true;
|
||||
char *restrict newvar = "Another string";
|
||||
|
||||
// Check varargs.
|
||||
test_varargs ("s, d' f .", "string", 65, 34.234);
|
||||
test_varargs_macros ();
|
||||
|
||||
// Check flexible array members.
|
||||
struct incomplete_array *ia =
|
||||
malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
|
||||
ia->datasize = 10;
|
||||
for (int i = 0; i < ia->datasize; ++i)
|
||||
ia->data[i] = i * 1.234;
|
||||
|
||||
// Check named initializers.
|
||||
struct named_init ni = {
|
||||
.number = 34,
|
||||
.name = L"Test wide string",
|
||||
.average = 543.34343,
|
||||
};
|
||||
|
||||
ni.number = 58;
|
||||
|
||||
int dynamic_array[ni.number];
|
||||
dynamic_array[ni.number - 1] = 543;
|
||||
|
||||
// work around unused variable warnings
|
||||
return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
|
||||
|| dynamic_array[ni.number - 1] != 543);
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99
|
||||
do
|
||||
CC="$ac_save_CC $ac_arg"
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
ac_cv_prog_cc_c99=$ac_arg
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext
|
||||
test "x$ac_cv_prog_cc_c99" != "xno" && break
|
||||
done
|
||||
rm -f conftest.$ac_ext
|
||||
CC=$ac_save_CC
|
||||
|
||||
fi
|
||||
# AC_CACHE_VAL
|
||||
case "x$ac_cv_prog_cc_c99" in
|
||||
x)
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
|
||||
$as_echo "none needed" >&6; } ;;
|
||||
xno)
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
|
||||
$as_echo "unsupported" >&6; } ;;
|
||||
*)
|
||||
CC="$CC $ac_cv_prog_cc_c99"
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5
|
||||
$as_echo "$ac_cv_prog_cc_c99" >&6; } ;;
|
||||
esac
|
||||
if test "x$ac_cv_prog_cc_c99" != xno; then :
|
||||
|
||||
fi
|
||||
|
||||
|
||||
CC="$save_CC"
|
||||
|
||||
wxCFLAGS_C99=$ac_cv_prog_cc_c99
|
||||
|
||||
|
||||
subdirs="$subdirs src/expat/expat"
|
||||
|
||||
fi
|
||||
|
11
configure.in
11
configure.in
@ -2721,6 +2721,17 @@ if test "$wxUSE_EXPAT" != "no"; then
|
||||
fi
|
||||
fi
|
||||
if test "$wxUSE_EXPAT" = "builtin" ; then
|
||||
dnl Expat requires C99 compiler, so define wxCFLAGS_C99 variable which
|
||||
dnl is used when compiling it in our makefiles.
|
||||
save_CC="$CC"
|
||||
AC_PROG_CC_C99
|
||||
CC="$save_CC"
|
||||
|
||||
dnl Note that we need just the flags, not the full CC value including
|
||||
dnl the compiler too.
|
||||
wxCFLAGS_C99=$ac_cv_prog_cc_c99
|
||||
AC_SUBST(wxCFLAGS_C99)
|
||||
|
||||
dnl Expat needs this:
|
||||
AC_CONFIG_SUBDIRS([src/expat/expat])
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user