diff --git a/include/msvcrt/string.h b/include/msvcrt/string.h index a821aa2..cc0b25e 100644 --- a/include/msvcrt/string.h +++ b/include/msvcrt/string.h @@ -18,8 +18,18 @@ typedef unsigned short wchar_t; #endif #endif
+#ifndef _MSC_VER +# ifndef __int64 +# define __int64 long long +# endif +#endif
#ifndef _SIZE_T_DEFINED +#ifdef _WIN64 +typedef unsigned __int64 size_t; +#else typedef unsigned int size_t; +#endif #define _SIZE_T_DEFINED #endif
Unfortunately, your changes to the submitted patch break it. The problem is that at this point _WIN64 is not defined yet. It is defined in windef.h which hasn't been included at this point. With your change, I still get the following compile-time error during compilation of dlls/msvcrt/test/data.c:
In file included from data.c:21: ./../msvcrt.h:625: error: conflicting types for _strnset ../../../include/msvcrt/string.h:62: error: previous declaration of _strnset was here
The patch I submitted fixes the problem by moving the include of "windef.h" a bit up:
diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index fc330ce..3da416d 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -36,11 +36,12 @@ #ifndef __WINE_MSVCRT_H #define __WINE_MSVCRT_H
+#include "windef.h" + #include <stdarg.h> #include <ctype.h> #include <string.h>
-#include "windef.h" #include "winbase.h" #include "winerror.h" #include "winnls.h"
Gé van Geldorp.
On 7/6/06, Ge van Geldorp ge@gse.nl wrote:
+#include "windef.h"
#include <stdarg.h>
On MSVC or at least older versions stdarg.h had to come before windef.h
"Ge van Geldorp" ge@gse.nl writes:
In file included from data.c:21: ./../msvcrt.h:625: error: conflicting types for _strnset ../../../include/msvcrt/string.h:62: error: previous declaration of _strnset was here
The patch I submitted fixes the problem by moving the include of "windef.h" a bit up:
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"
From: Alexandre Julliard
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"
Yes, this works fine, both with and without the change to include/msvcrt/string.h.
Best regards, Ge van Geldorp.
From: Alexandre Julliard [mailto:julliard@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.
"Ge van Geldorp" ge@gse.nl writes:
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?
Unfortunately that's not how MS does it.
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).
We should probably do that, yes.