diff options
author | thevenyp <thevenyp@280ebfd0-de03-0410-8827-d642c229c3f4> | 2008-06-10 14:18:37 +0000 |
---|---|---|
committer | thevenyp <thevenyp@280ebfd0-de03-0410-8827-d642c229c3f4> | 2008-06-10 14:18:37 +0000 |
commit | 6d7d71118b05dac6c40766a2d2334e7c1d5ad02b (patch) | |
tree | 267bc853602fb5e583e5a9afa53183de959907ce | |
parent | bb13b553727db6a5874547c74a24b14f30658999 (diff) | |
download | mpfr-6d7d71118b05dac6c40766a2d2334e7c1d5ad02b.tar.gz |
Change #include <stdio.h> to #include <cstdio> when compiled with a C++ compiler.
Assume that mpfr_rnd_t and wchar_t arguments in a variadic functions are converted to 'int' by C++ compilers.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@5389 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | mpfr-impl.h | 4 | ||||
-rw-r--r-- | tests/mpf_compat.h | 4 | ||||
-rw-r--r-- | tests/tsprintf.c | 5 | ||||
-rw-r--r-- | vasprintf.c | 37 |
4 files changed, 39 insertions, 11 deletions
diff --git a/mpfr-impl.h b/mpfr-impl.h index 7ca2d9717..a00363287 100644 --- a/mpfr-impl.h +++ b/mpfr-impl.h @@ -31,7 +31,11 @@ MA 02110-1301, USA. */ (which is very unlikely and probably means something broken in this source file), we should do that with some macro (that would also force to disable incompatible features). */ +#if defined (__cplusplus) +#include <cstdio> +#else #include <stdio.h> +#endif #include <limits.h> /* Check if we are inside a build of MPFR or inside the test suite. diff --git a/tests/mpf_compat.h b/tests/mpf_compat.h index cccbb1941..d26bf5f62 100644 --- a/tests/mpf_compat.h +++ b/tests/mpf_compat.h @@ -20,7 +20,11 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ +#if defined (__cplusplus) +#include <cstdio> +#else #include <stdio.h> +#endif #include <stdlib.h> #include <string.h> diff --git a/tests/tsprintf.c b/tests/tsprintf.c index ea22110fd..60fc80ca1 100644 --- a/tests/tsprintf.c +++ b/tests/tsprintf.c @@ -22,7 +22,12 @@ MA 02110-1301, USA. */ #ifdef HAVE_STDARG #include <stdarg.h> +#if defined (__cplusplus) +#include <cstdio> +#else #include <stdio.h> +#endif + #include <stdlib.h> #include <string.h> diff --git a/vasprintf.c b/vasprintf.c index 1ba21602a..828f63f91 100644 --- a/vasprintf.c +++ b/vasprintf.c @@ -34,7 +34,17 @@ MA 02110-1301, USA. */ #include <stdint.h> #endif +#if defined (__cplusplus) +#include <cstddef> +#else #include <stddef.h> /* for ptrdiff_t */ +#endif + +/* SIZE_MAX should be defined in stddef.h but maybe not in cstddef */ +#ifndef SIZE_MAX +#define SIZE_MAX 65535 +#endif + #include <string.h> /* for strlen */ #include "mpfr-impl.h" @@ -312,17 +322,22 @@ parse_arg_type (const char *format, struct printf_spec *specinfo) #define CASE_INTMAX_ARG(specinfo, ap) #endif +/* With a C++ compiler wchar_t and enumeration in va_list are converted to + integer type : int, unsigned int, long or unsigned long (unfortunatly, + this is implementation dependant). + We follow gmp which assumes in print/doprnt.c that wchar_t is converted + to int. */ #ifdef HAVE_WCHAR_H -#define CASE_LONG_ARG(specinfo, ap) \ - case LONG_ARG: \ - if (((specinfo).spec == 'd') || ((specinfo).spec == 'i') \ - || ((specinfo).spec == 'o') || ((specinfo).spec == 'u') \ - || ((specinfo).spec == 'x') || ((specinfo).spec == 'X')) \ - (void) va_arg ((ap), long); \ - else if ((specinfo).spec == 'c') \ - (void) va_arg ((ap), wint_t); \ - else if ((specinfo).spec == 's') \ - (void) va_arg ((ap), wchar_t); \ +#define CASE_LONG_ARG(specinfo, ap) \ + case LONG_ARG: \ + if (((specinfo).spec == 'd') || ((specinfo).spec == 'i') \ + || ((specinfo).spec == 'o') || ((specinfo).spec == 'u') \ + || ((specinfo).spec == 'x') || ((specinfo).spec == 'X')) \ + (void) va_arg ((ap), long); \ + else if ((specinfo).spec == 'c') \ + (void) va_arg ((ap), wint_t); \ + else if ((specinfo).spec == 's') \ + (void) va_arg ((ap), int); /* let assume integer promotion */ \ break; #else #define CASE_LONG_ARG(specinfo, ap) \ @@ -1843,7 +1858,7 @@ mpfr_vasprintf (char **ptr, const char *fmt, va_list ap) break; case '*': ++fmt; - spec.rnd_mode = va_arg (ap, mp_rnd_t); + spec.rnd_mode = (mpfr_rnd_t) va_arg (ap, int); break; case 'D': ++fmt; |