• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2002-2004, 2006-2018 Free Software Foundation, Inc.
2# This file is free software; the Free Software Foundation
3# gives unlimited permission to copy and/or distribute it,
4# with or without modifications, as long as this notice is preserved.
5
6# Test whether the *printf family of functions supports 'long double'
7# arguments together with the 'L' size specifier. (ISO C99, POSIX:2001)
8# Result is gl_cv_func_printf_long_double.
9
10printf_long_double_test = '''
11#include <stdio.h>
12#include <string.h>
13static char buf[10000];
14int main ()
15{
16  int result = 0;
17  buf[0] = '\0';
18  if (sprintf (buf, "%Lf %d", 1.75L, 33, 44, 55) < 0
19      || strcmp (buf, "1.750000 33") != 0)
20    result |= 1;
21  buf[0] = '\0';
22  if (sprintf (buf, "%Le %d", 1.75L, 33, 44, 55) < 0
23      || strcmp (buf, "1.750000e+00 33") != 0)
24    result |= 2;
25  buf[0] = '\0';
26  if (sprintf (buf, "%Lg %d", 1.75L, 33, 44, 55) < 0
27      || strcmp (buf, "1.75 33") != 0)
28    result |= 4;
29  return result;
30}
31'''
32
33if not meson.is_cross_build() or meson.has_exe_wrapper()
34  run_result = cc.run(printf_long_double_test,
35      name : 'printf supports \'long double\' arguments')
36  gl_cv_func_printf_long_double = run_result.compiled() and run_result.returncode() == 0
37else
38 if host_system.startswith ('beos')
39   gl_cv_func_printf_long_double = false
40 elif host_system == 'windows'
41   # Guess yes on MSVC, no on mingw.
42   if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
43     gl_cv_func_printf_long_double = true
44   else
45     gl_cv_func_printf_long_double = false
46   endif
47 else
48   gl_cv_func_printf_long_double = true
49 endif
50endif
51