[PATCH] Fix include file ordering in libc/stdlib/mb*.c

J. Johnston jjohnstn@redhat.com
Mon Dec 22 20:59:00 GMT 2003


Chris,

   I think the real solution should be to include <sys/reent.h> in wchar.h. 
Alternatively, a simple struct _reent; declaration would stop the problem. 
Otherwise, the end-user will run into the same problem.

   I will check this in shortly.

-- Jeff J.

Christopher Faylor wrote:
> Although this patch is relatively large, I've checked this in as a
> trivial fix.  Without this, mbrtowc.c and friends do not compile with
> the header in libc/include/wchar.h since gcc gets confused by the
> missing struct _reent definition.  Moving the reent.h include earlier
> seems to fix things.
> 
> The multiple ChangeLog entries came about due to the fact that I kept
> noticing more and more of these problems as I was trying to build a
> cygwin snapshot.
> 
> cgf
> 
> 2003-12-05  Christopher Faylor  <cgf@redhat.com>
> 
>         * libc/stdlib/mbrlen.c: Change include order to prevent compiler errors
>         when defining _mbrtowc.
>         * libc/stdlib/mbsinit.c: Ditto.
>         * libc/stdlib/mbsrtowcs.c: Ditto.
>         * libc/stdlib/wcrtomb.c: Ditto.
>         * libc/stdlib/wcsrtombs.c: Ditto.
>         * libc/stdlib/wctob.c: Ditto.
> 
> 2003-12-05  Christopher Faylor  <cgf@redhat.com>
>  
> 	* libc/stdlib/mbrlen.c: Change include order to prevent compiler
> 	errors when defining _mbrtowc.
> 	* libc/stdlib/mbsinit.c: Ditto.
> 	* libc/stdlib/mbsrtowcs.c: Ditto.
> 
> 2003-12-05  Christopher Faylor  <cgf@redhat.com>
> 
>  	* libc/stdlib/mbrtowc.c: Change include order to prevent compiler
>  	errors when defining _mbrtowc.
> 
> Index: libc/stdlib/mbrtowc.c
> ===================================================================
> RCS file: /cvs/uberbaum/newlib/libc/stdlib/mbrtowc.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 mbrtowc.c
> --- libc/stdlib/mbrtowc.c	9 Sep 2002 21:42:14 -0000	1.2
> +++ libc/stdlib/mbrtowc.c	5 Dec 2003 06:01:54 -0000
> @@ -1,7 +1,7 @@
> +#include <reent.h>
>  #include <wchar.h>
>  #include <stdlib.h>
>  #include <stdio.h>
> -#include <reent.h>
>  #include <errno.h>
>  #include <string.h>
>  
> Index: libc/stdlib/mbrlen.c
> ===================================================================
> RCS file: /cvs/uberbaum/newlib/libc/stdlib/mbrlen.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 mbrlen.c
> --- libc/stdlib/mbrlen.c	9 Sep 2002 21:42:14 -0000	1.2
> +++ libc/stdlib/mbrlen.c	5 Dec 2003 06:08:03 -0000
> @@ -1,7 +1,7 @@
> +#include <reent.h>
>  #include <wchar.h>
>  #include <stdlib.h>
>  #include <stdio.h>
> -#include <reent.h>
>  #include <errno.h>
>  
>  size_t
> Index: libc/stdlib/mbsinit.c
> ===================================================================
> RCS file: /cvs/uberbaum/newlib/libc/stdlib/mbsinit.c,v
> retrieving revision 1.1
> diff -u -p -r1.1 mbsinit.c
> --- libc/stdlib/mbsinit.c	23 Aug 2002 01:56:04 -0000	1.1
> +++ libc/stdlib/mbsinit.c	5 Dec 2003 06:08:03 -0000
> @@ -1,7 +1,7 @@
> +#include <reent.h>
>  #include <wchar.h>
>  #include <stdlib.h>
>  #include <stdio.h>
> -#include <reent.h>
>  #include <errno.h>
>  
>  int
> Index: libc/stdlib/mbsrtowcs.c
> ===================================================================
> RCS file: /cvs/uberbaum/newlib/libc/stdlib/mbsrtowcs.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 mbsrtowcs.c
> --- libc/stdlib/mbsrtowcs.c	9 Sep 2002 21:42:14 -0000	1.2
> +++ libc/stdlib/mbsrtowcs.c	5 Dec 2003 06:08:03 -0000
> @@ -1,7 +1,7 @@
> +#include <reent.h>
>  #include <wchar.h>
>  #include <stdlib.h>
>  #include <stdio.h>
> -#include <reent.h>
>  #include <errno.h>
>  
>  size_t
> Index: libc/stdlib/wcrtomb.c
> ===================================================================
> RCS file: /cvs/uberbaum/newlib/libc/stdlib/wcrtomb.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 wcrtomb.c
> --- libc/stdlib/wcrtomb.c	9 Sep 2002 21:42:14 -0000	1.2
> +++ libc/stdlib/wcrtomb.c	5 Dec 2003 06:13:18 -0000
> @@ -1,7 +1,7 @@
> +#include <reent.h>
>  #include <wchar.h>
>  #include <stdlib.h>
>  #include <stdio.h>
> -#include <reent.h>
>  #include <errno.h>
>  
>  size_t
> Index: libc/stdlib/wcsrtombs.c
> ===================================================================
> RCS file: /cvs/uberbaum/newlib/libc/stdlib/wcsrtombs.c,v
> retrieving revision 1.3
> diff -u -p -r1.3 wcsrtombs.c
> --- libc/stdlib/wcsrtombs.c	6 Nov 2003 00:46:59 -0000	1.3
> +++ libc/stdlib/wcsrtombs.c	5 Dec 2003 06:13:18 -0000
> @@ -1,7 +1,7 @@
> +#include <reent.h>
>  #include <wchar.h>
>  #include <stdlib.h>
>  #include <stdio.h>
> -#include <reent.h>
>  #include <errno.h>
>  
>  size_t
> Index: libc/stdlib/wctob.c
> ===================================================================
> RCS file: /cvs/uberbaum/newlib/libc/stdlib/wctob.c,v
> retrieving revision 1.1
> diff -u -p -r1.1 wctob.c
> --- libc/stdlib/wctob.c	23 Aug 2002 01:56:04 -0000	1.1
> +++ libc/stdlib/wctob.c	5 Dec 2003 06:13:18 -0000
> @@ -1,8 +1,7 @@
> -#include <wchar.h>
> +#include <reent.h>
>  #include <wchar.h>
>  #include <stdlib.h>
>  #include <stdio.h>
> -#include <reent.h>
>  
>  int
>  wctob (wint_t c)



More information about the Newlib mailing list