?RCS: Copyright (c) 2006-2007, H.Merijn Brand
?RCS:
?RCS: You may redistribute only under the terms of the Artistic License,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
?RCS: that same Artistic License; a copy of which may be found at the root
?RCS: of the source tree for dist 3.0.
?RCS:
?MAKE:d_c99_variadic_macros: Compile Setvar cat rm_try run
?MAKE:	-pick add $@ %<
?S:d_c99_variadic_macros:
?S:	This variable conditionally defines the HAS_C99_VARIADIC_MACROS
?S:	symbol, which indicates to the C program that C99 variadic macros
?S:	are available.
?S:.
?C:HAS_C99_VARIADIC_MACROS:
?C:	If defined, the compiler supports C99 variadic macros.
?C:.
?H:#$d_c99_variadic_macros	HAS_C99_VARIADIC_MACROS	/**/
?H:.
?F:!try
: see if the Compiler supports C99 variadic macros
echo "Checking for C99 variadic macros." >&4
$cat >try.c <<EOCP
#include <stdio.h>
#include <stdarg.h>

#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
$rm_try

