From: Nicholas Clark Date: Sat, 13 May 2006 15:48:24 +0000 (+0000) Subject: A Configure probe for C99 variadic macros, based on code from Jarkko. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9802685f01199cb057aa21dd571a78932fb81070;p=p5sagit%2Fp5-mst-13.2.git A Configure probe for C99 variadic macros, based on code from Jarkko. p4raw-id: //depot/perl@28189 --- diff --git a/Configure b/Configure index 6ddb054..a4b4887 100755 --- a/Configure +++ b/Configure @@ -383,6 +383,7 @@ d_ctermid_r='' ctime_r_proto='' d_ctime_r='' d_cuserid='' +d_c99_variadic_macros='' d_dbl_dig='' d_dbminitproto='' d_difftime='' @@ -19164,6 +19165,46 @@ EOCP ;; esac +: see if the Compiler supports C99 variadic macros +case "$i_stdarg$i_stdlib" in + "$define$define") + echo "You have and , so checking for C99 variadic macros." >&4 + $cat >try.c < +#include + +#define foo(buffer, format, ...) sprintf(buffer, format, __VA_ARGS__) + +int main() { + char buf[20]; + foo(buf, "%d %g %.*s", 123, 456.0, (int)3, "789fail"); + puts(buf); + return 0; +} +EOCP + set try + if eval $compile && $run ./try 2>&1 >/dev/null; then + case "`$run ./try`" in + "123 456 789") + echo "You have C99 variadic macros." >&4 + d_c99_variadic_macros="$define" + ;; + *) + echo "You don't have functional C99 variadic macros." >&4 + d_c99_variadic_macros="$undef" + ;; + esac + else + echo "I couldn't compile and run the test program, so I assume that you don't have functional C99 variadic macros." >&4 + d_c99_variadic_macros="$undef" + fi + ;; + *) + echo "You don't have and , so not checking for C99 variadic macros." >&4 + d_c99_variadic_macros="$undef" + ;; +esac + : see what type is used for size_t rp="What is the type used for the length parameter for string functions?" set size_t sizetype 'unsigned int' stdio.h sys/types.h @@ -21276,6 +21317,7 @@ d_csh='$d_csh' d_ctermid_r='$d_ctermid_r' d_ctime_r='$d_ctime_r' d_cuserid='$d_cuserid' +d_c99_variadic_macros='$d_c99_variadic_macros' d_dbl_dig='$d_dbl_dig' d_dbminitproto='$d_dbminitproto' d_difftime='$d_difftime' diff --git a/Cross/config.sh-arm-linux b/Cross/config.sh-arm-linux index de83224..863c44a 100644 --- a/Cross/config.sh-arm-linux +++ b/Cross/config.sh-arm-linux @@ -141,6 +141,7 @@ d_crypt_r='undef' d_csh='define' d_ctermid_r='undef' d_ctime_r='undef' +d_c99_variadic_macros='undef' d_cuserid='define' d_dbl_dig='define' d_dbminitproto='undef' diff --git a/NetWare/config.wc b/NetWare/config.wc index 005a1d2..511ebf3 100644 --- a/NetWare/config.wc +++ b/NetWare/config.wc @@ -129,6 +129,7 @@ d_crypt_r='undef' d_csh='undef' d_ctermid_r='undef' d_ctime_r='undef' +d_c99_variadic_macros='undef' d_cuserid='undef' d_dbl_dig='define' d_dbminitproto='undef' diff --git a/Porting/Glossary b/Porting/Glossary index 35e0e8b..767db1c 100644 --- a/Porting/Glossary +++ b/Porting/Glossary @@ -558,6 +558,11 @@ d_ctime_r (d_ctime_r.U): which indicates to the C program that the ctime_r() routine is available. +d_c99_variadic_macros (d_c99_variadic_macros.U): + This variable conditionally defines the HAS_C99_VARIADIC_MACROS + symbol, which indicates to the C program that C99 variadic macros + are available. + d_cuserid (d_cuserid.U): This variable conditionally defines the HAS_CUSERID symbol, which indicates to the C program that the cuserid() routine is available diff --git a/config_h.SH b/config_h.SH index 4639102..ee4c292 100644 --- a/config_h.SH +++ b/config_h.SH @@ -4421,4 +4421,10 @@ sed <$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un #endif #endif + +/* HAS_C99_VARIADIC_MACROS: + * If defined, the compiler supports C99 variadic macros. + */ +#$d_c99_variadic_macros HAS_C99_VARIADIC_MACROS /**/ + !GROK!THIS! diff --git a/configure.com b/configure.com index 62e4192..b8d6da7 100644 --- a/configure.com +++ b/configure.com @@ -5703,6 +5703,7 @@ $ WC "d_copysignl='define'" $ WC "d_crypt='define'" $ WC "d_csh='undef'" $ WC "d_cuserid='define'" +$ WC "d_c99_variadic_macros='undef'" $ WC "d_dbl_dig='define'" $ WC "d_dbminitproto='undef'" $ WC "d_difftime='define'" diff --git a/epoc/config.sh b/epoc/config.sh index d7e9469..217b6c8 100644 --- a/epoc/config.sh +++ b/epoc/config.sh @@ -134,6 +134,7 @@ d_crypt_r='undef' d_csh='undef' d_ctermid_r='undef' d_ctime_r='undef' +d_c99_variadic_macros='undef' d_cuserid='undef' d_dbl_dig='undef' d_dbminitproto='undef' diff --git a/plan9/config_sh.sample b/plan9/config_sh.sample index ddf15cc..8697741 100644 --- a/plan9/config_sh.sample +++ b/plan9/config_sh.sample @@ -141,6 +141,7 @@ d_crypt_r='undef' d_csh='undef' d_ctermid_r='undef' d_ctime_r='undef' +d_c99_variadic_macros='undef' d_cuserid='define' d_dbl_dig='define' d_dbminitproto='undef' diff --git a/symbian/config.sh b/symbian/config.sh index b1bb772..2e7327f 100644 --- a/symbian/config.sh +++ b/symbian/config.sh @@ -83,6 +83,7 @@ d_crypt_r='undef' d_csh='undef' d_ctermid_r='undef' d_ctime_r='undef' +d_c99_variadic_macros='undef' d_cuserid='undef' d_dbl_dig='undef' d_dbminitproto='undef' diff --git a/uconfig.sh b/uconfig.sh index fe046a7..dc49402 100755 --- a/uconfig.sh +++ b/uconfig.sh @@ -72,6 +72,7 @@ d_crypt_r='undef' d_csh='undef' d_ctermid_r='undef' d_ctime_r='undef' +d_c99_variadic_macros='undef' d_cuserid='undef' d_dbl_dig='undef' d_dbminitproto='undef' diff --git a/win32/config.bc b/win32/config.bc index 60d615b..d460097 100644 --- a/win32/config.bc +++ b/win32/config.bc @@ -131,6 +131,7 @@ d_crypt_r='undef' d_csh='undef' d_ctermid_r='undef' d_ctime_r='undef' +d_c99_variadic_macros='undef' d_cuserid='undef' d_dbl_dig='define' d_dbminitproto='undef' diff --git a/win32/config.gc b/win32/config.gc index 2f5bc67..da97c1a 100644 --- a/win32/config.gc +++ b/win32/config.gc @@ -131,6 +131,7 @@ d_crypt_r='undef' d_csh='undef' d_ctermid_r='undef' d_ctime_r='undef' +d_c99_variadic_macros='undef' d_cuserid='undef' d_dbl_dig='define' d_dbminitproto='undef' diff --git a/win32/config.vc b/win32/config.vc index 89e3242..ec90484 100644 --- a/win32/config.vc +++ b/win32/config.vc @@ -131,6 +131,7 @@ d_crypt_r='undef' d_csh='undef' d_ctermid_r='undef' d_ctime_r='undef' +d_c99_variadic_macros='undef' d_cuserid='undef' d_dbl_dig='define' d_dbminitproto='undef' diff --git a/win32/config.vc64 b/win32/config.vc64 index 6e5c748..bcda881 100644 --- a/win32/config.vc64 +++ b/win32/config.vc64 @@ -131,6 +131,7 @@ d_crypt_r='undef' d_csh='undef' d_ctermid_r='undef' d_ctime_r='undef' +d_c99_variadic_macros='undef' d_cuserid='undef' d_dbl_dig='define' d_dbminitproto='undef'