2018-01-20 02:14:59 -05:00
|
|
|
# -*- Autoconf -*-
|
2018-01-20 02:05:25 -05:00
|
|
|
AC_DEFUN([RUBY_CHECK_PRINTF_PREFIX], [
|
|
|
|
AC_CACHE_CHECK([for printf prefix for $1], [rb_cv_pri_prefix_]AS_TR_SH($1),[
|
|
|
|
[rb_cv_pri_prefix_]AS_TR_SH($1)=[NONE]
|
|
|
|
RUBY_WERROR_FLAG(RUBY_APPEND_OPTIONS(CFLAGS, $rb_cv_wsuppress_flags)
|
|
|
|
for pri in $2; do
|
2020-12-12 08:55:09 -05:00
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <stdio.h>
|
2018-01-20 02:05:25 -05:00
|
|
|
@%:@include <stddef.h>
|
|
|
|
@%:@ifdef __GNUC__
|
2018-09-04 04:39:14 -04:00
|
|
|
@%:@if defined __MINGW_PRINTF_FORMAT
|
2018-09-03 04:20:41 -04:00
|
|
|
@%:@define PRINTF_ARGS(decl, string_index, first_to_check) \
|
2018-09-04 04:39:14 -04:00
|
|
|
decl __attribute__((format(__MINGW_PRINTF_FORMAT, string_index, first_to_check)))
|
2018-09-03 04:20:41 -04:00
|
|
|
@%:@else
|
2018-01-20 02:05:25 -05:00
|
|
|
@%:@define PRINTF_ARGS(decl, string_index, first_to_check) \
|
|
|
|
decl __attribute__((format(printf, string_index, first_to_check)))
|
2018-09-03 04:20:41 -04:00
|
|
|
@%:@endif
|
2018-01-20 02:05:25 -05:00
|
|
|
@%:@else
|
|
|
|
@%:@define PRINTF_ARGS(decl, string_index, first_to_check) decl
|
|
|
|
@%:@endif
|
2020-12-12 08:55:09 -05:00
|
|
|
PRINTF_ARGS(void test_sprintf(const char*, ...), 1, 2);]],
|
|
|
|
[[printf("%]${pri}[d", (]$1[)42);
|
|
|
|
test_sprintf("%]${pri}[d", (]$1[)42);]])],
|
2018-01-20 02:05:25 -05:00
|
|
|
[rb_cv_pri_prefix_]AS_TR_SH($1)[=[$pri]; break])
|
|
|
|
done)])
|
|
|
|
AS_IF([test "[$rb_cv_pri_prefix_]AS_TR_SH($1)" != NONE], [
|
|
|
|
AC_DEFINE_UNQUOTED([PRI_]m4_ifval($3,$3,AS_TR_CPP(m4_bpatsubst([$1],[_t$])))[_PREFIX],
|
|
|
|
"[$rb_cv_pri_prefix_]AS_TR_SH($1)")
|
|
|
|
])
|
|
|
|
])dnl
|