include/msvcrt: Make sure size_t is properly defined for 64-bit.

Ge van Geldorp ge at gse.nl
Sun Jul 9 15:38:57 CDT 2006


> From: Alexandre Julliard [mailto:julliard at winehq.org] 
> 
> We really shouldn't be including string.h here. Does this work for
> you?
> 
> diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h
> index fc330ce..dcba4ae 100644
> --- a/dlls/msvcrt/msvcrt.h
> +++ b/dlls/msvcrt/msvcrt.h
> @@ -37,8 +37,6 @@
>  #ifndef __WINE_MSVCRT_H
>  #define __WINE_MSVCRT_H
>  
>  #include <stdarg.h>
> -#include <ctype.h>
> -#include <string.h>
>  
>  #include "windef.h"
>  #include "winbase.h"

I did some more researching. The patch above does fix the compile-time
error. However, I still get compile-time warnings related to size_t (they
also occur with my original patch BTW):

(e.g. during compilation of dlls/msvcrt/tests/cpp.c)
In file included from ../../../include/wine/test.h:25,
                 from cpp.c:30:
../../../include/msvcrt/stdlib.h:154: warning: conflicting types for
built-in function calloc
In file included from ../../../include/winnt.h:29,
                 from ../../../include/windef.h:234,
                 from ../../../include/wine/test.h:26,
                 from cpp.c:30:
../../../include/msvcrt/string.h:68: warning: conflicting types for built-in
function memcmp

(plus a bunch of warnings for other built-in functions).
Although they are only warnings, they do point to a real problem: size_t is
defined as a 32-bit type but it should be a 64-bit type. size_t is defined
in a number of places in include/msvcrt:

direct.h
malloc.h
mbstring.h
search.h
stddef.h
stdio.h
stdlib.h
string.h
time.h
wchar.h

Most of these places use "typedef unsigned int size_t", while currently
stddef.h and string.h try to do the correct thing depending on whether
_WIN64 is defined, which doesn't work because that symbol is only defined if
either windef.h or basetsd.h were included before.
I'm not sure why the typedef is duplicated so many times. Wouldn't it be
better to define it only in stddef.h, #ifdef'ing it on __x86_64__ and then
include stddef.h from the other files?
Another option might be to add -D_WIN64 to EXTRACFLAGS in dlls/Makedll.rules
and programs/Makeprogs.rules. This would mimic the behaviour of MSVC better
(it has _WIN64 predefined).

Ge van Geldorp.




More information about the wine-devel mailing list