xref: /netbsd-src/external/lgpl3/mpfr/dist/tests/tvalist.c (revision b83ebeba7f767758d2778bb0f9d7a76534253621)
1 /* Test file for multiple mpfr.h inclusion and va_list related functions
2 
3 Copyright 2011, 2012, 2013 Free Software Foundation, Inc.
4 Contributed by the AriC and Caramel projects, INRIA.
5 
6 This file is part of the GNU MPFR Library.
7 
8 The GNU MPFR Library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12 
13 The GNU MPFR Library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16 License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License
19 along with the GNU MPFR Library; see the file COPYING.LESSER.  If not, see
20 http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
21 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
22 
23 #if HAVE_STDARG
24 
25 #if _MPFR_EXP_FORMAT == 4
26 /* If mpfr_exp_t is defined as intmax_t, intmax_t must be defined before
27    the inclusion of mpfr.h (this test doesn't use mpfr-impl.h). */
28 # include <stdint.h>
29 #endif
30 
31 /* Assume that this is in fact a header inclusion for some library
32    that uses MPFR, i.e. this inclusion is hidden in another one.
33    MPFR currently (rev 6704) fails to handle this case. */
34 #include <mpfr.h>
35 
36 #include <stdarg.h>
37 #define MPFR_USE_VA_LIST /* necessary due to GMP bug concerning inclusions */
38 #include <mpfr.h>
39 
40 #include <stdio.h>
41 #define MPFR_USE_FILE /* necessary due to GMP bug concerning inclusions */
42 #include <mpfr.h>
43 
44 static void
45 test (FILE *fout, const char *fmt, ...)
46 {
47   int (*fct) (FILE*, __gmp_const char*, va_list);
48 
49   fct = mpfr_vfprintf;
50   if (0)
51     {
52       va_list ap;
53       va_start (ap, fmt);
54       fct (fout, fmt, ap);
55       va_end (ap);
56     }
57 }
58 
59 int
60 main (void)
61 {
62   test (stdout, "%d\n", 0);
63   return 0;
64 }
65 
66 #else  /* HAVE_STDARG */
67 
68 /* The test is disabled. */
69 
70 int
71 main (void)
72 {
73   return 77;
74 }
75 
76 #endif  /* HAVE_STDARG */
77