|
2001-07-19
| ||
| 14:04 | • Closed ticket [442178ffff]: Cygwin TCHAR in tclPlatDecls.h fix plus 7 other ... artifact: ba619e488d user: mdejong | |
| 11:57 | • Ticket [442178ffff]: 4 changes artifact: ddbd9a414f user: hobbs | |
|
2001-07-18
| ||
| 15:22 | • Ticket [442178ffff]: 4 changes artifact: 1f88a2cb3c user: mdejong | |
| 13:27 | • Ticket [442178ffff]: 4 changes artifact: 3cfc01259f user: mdejong | |
| 08:51 | • Ticket [442178ffff]: 4 changes artifact: 0ebd51a46e user: davygrvy | |
| 07:43 | • Ticket [442178ffff]: 4 changes artifact: d7a3e4d980 user: mdejong | |
| 07:28 | • Ticket [442178ffff]: 4 changes artifact: 996d51892e user: davygrvy | |
| 07:28 | • Ticket [442178ffff]: 4 changes artifact: 0cb0d8520c user: davygrvy | |
| 07:28 | • Add attachment patch3.txt to ticket [442178ffff] artifact: 3d225c721b user: davygrvy | |
| 07:24 | • Ticket [442178ffff] Cygwin TCHAR in tclPlatDecls.h fix status still Open wit... artifact: 9ba1d18b13 user: davygrvy | |
| 05:11 | • Ticket [442178ffff]: 4 changes artifact: b33458af10 user: mdejong | |
| 05:11 | • Add attachment patch to ticket [442178ffff] artifact: 5f2d3dc671 user: mdejong | |
|
2001-07-17
| ||
| 22:11 | • New ticket [442178ffff] Cygwin TCHAR in tclPlatDecls.h fix. artifact: c3edf2e904 user: mdejong | |
Cygwin TCHAR in tclPlatDecls.h fix
Closed / Accepted442178ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2001-07-17 22:11:51
This patch should fix the last of the Cygwin include errors. I wanted to have David Gravereaux take a look at this since he has worked in this code before. The problem is that Cygwin does not have a <tchar.h> file. The TCHAR type is defined in <winnt.h> but you need to pull in <windows.h> to get at it. Does this seem ok? I took out the bit that checks for _INC_TCHAR because that should not be needed and it is MSVC specific. I also made it depend on _MSC_VER instead of __WIN32__ since Cygwin, Mingw, and VC++ each define __WIN32__.
mdejongplain2001-07-18 05:11:52
File Added - 8538: patch
davygrvyplain2001-07-18 07:24:53
File Added - 8544: patch2.txt Logged In: YES user_id=7549 yeah, I see where you're going with this. Lets not forget borland, too. How does this look?
davygrvyplain2001-07-18 07:28:03
File Added - 8545: patch3.txt Logged In: YES user_id=7549 whoop.. forgot a closing #endif.
davygrvyplain2001-07-18 07:28:50
File Deleted - 8544:
mdejongplain2001-07-18 07:43:52
Logged In: YES
user_id=90858
I looked at the patch, but I still don't understand what
that "elif !defined(_INC_TCHAR)" bit is for. The MSVC
include file checks to see if _INC_TCHAR is defined
so there is no danger of including tchar.h twice:
% cat t3.c
#include <tchar.h>
#include <tchar.h>
int main() {}
% cl -c t3.c
What is up with that?
Why not just do this:
#if defined(__WIN32__)
# if defined(__CYGWIN__)
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# undef WIN32_LEAN_AND_MEAN
# else
# include <tchar.h>
# endif
#endif
Or, if it does not matter, could we just do this?
#ifdef __WIN32__
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# undef WIN32_LEAN_AND_MEAN
#endif
davygrvyplain2001-07-18 08:51:35
Logged In: YES user_id=7549 Oh. tchar.h isn't in the platform SDK. I understand. #if defined(__WIN32__) && !define(_TCHAR_DEFINED) # define WIN32_LEAN_AND_MEAN # include <windows.h> # undef WIN32_LEAN_AND_MEAN #endif What would be nicer, might be the expansion of TCHAR instead. This is the external API and TCHAR has different meanings with _UNICODE and _MCBS defined.
mdejongplain2001-07-18 13:27:02
Logged In: YES user_id=90858 Humm, that is an interesting point. If you look at the top of the tclWinPort.h file, you will find the following: #ifndef _TCLINT # include "tclInt.h" #endif #ifdef CHECK_UNICODE_CALLS #define _UNICODE #define UNICODE #define __TCHAR_DEFINED typedef float *_TCHAR; #define _TCHAR_DEFINED typedef float *TCHAR; #endif I was under the impression that defining _UNICODE and then pulling in <windows.h> would define TCHAR as wchar_t. It seems odd that it is already typedefed as a float* here. Any idea what is going on there? If we pull in <windows.h> in tclPlatDecls.h then it will not be defined the same way as in tclWinPort.h because _UNICODE is not defined. Also, it seems like <windows.h> is getting pulled in multiple times, even when it is not needed. For example, removing this include seems fine since <tclPort.h> already pulls <tclWinPort.h> which includes <windows.h>. There is also one in tclAppInit.c, but I am not sure about that on. diff -u -r1.12 tclWinReg.c --- win/tclWinReg.c 2000/06/13 20:30:24 1.12 +++ win/tclWinReg.c 2001/07/18 06:20:08 @@ -17,10 +17,6 @@ #include <tclPort.h> #include <stdlib.h> -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#undef WIN32_LEAN_AND_MEAN -
mdejongplain2001-07-18 15:22:13
Logged In: YES user_id=90858 Ok, I took another look at things and I think one of these two options is the ticket. The first option is to pull <windows.h> into tclPlatDecls.h. This moves the currently unused TCHAR defines in the CHECK_UNICODE_DEFINES block. Index: generic/tclPlatDecls.h =================================================================== RCS file: /cvsroot/tcl/tcl/generic/tclPlatDecls.h,v retrieving revision 1.6 diff -u -r1.6 tclPlatDecls.h --- generic/tclPlatDecls.h2000/08/20 03:51:231.6 +++ generic/tclPlatDecls.h2001/07/18 08:04:32 @@ -13,13 +13,29 @@ #define _TCLPLATDECLS /* - * Pull in the definition of TCHAR. Hopefully the compile flags - * of the core are matching against your project build for these - * public functions. BE AWARE. + * Define TCHAR by pulling in <windows.h>. If the + * core uses unicode but an extension does not, a compile + * time error should be generated. BE AWARE. */ -#if defined(__WIN32__) && !defined(_INC_TCHAR) -#include <tchar.h> -#endif +#ifdef __WIN32__ + +#ifdef CHECK_UNICODE_CALLS + +#define _UNICODE +#define UNICODE + +#define __TCHAR_DEFINED +typedef float *_TCHAR; + +#define _TCHAR_DEFINED +typedef float *TCHAR; + +#endif /* CHECK_UNICODE_CALLS */ + +# define WIN32_LEAN_AND_MEAN +# include <windows.h> +# undef WIN32_LEAN_AND_MEAN +#endif /* __WIN32__ */ /* !BEGIN!: Do not edit below this line. */ Index: win/tclWinPort.h =================================================================== RCS file: /cvsroot/tcl/tcl/win/tclWinPort.h,v retrieving revision 1.16 diff -u -r1.16 tclWinPort.h --- win/tclWinPort.h2001/07/17 18:33:241.16 +++ win/tclWinPort.h2001/07/18 08:04:32 @@ -20,19 +20,6 @@ # include "tclInt.h" #endif -#ifdef CHECK_UNICODE_CALLS - -#define _UNICODE -#define UNICODE - -#define __TCHAR_DEFINED -typedef float *_TCHAR; - -#define _TCHAR_DEFINED -typedef float *TCHAR; - -#endif - /* *--------------------------------------------------------------------------- * The following sets of #includes and #ifdefs are required to get Tcl to @@ -66,10 +53,6 @@ #include <time.h> #include <winsock.h> -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#undef WIN32_LEAN_AND_MEAN - #ifdef BUILD_tcl # undef TCL_STORAGE_CLASS # define TCL_STORAGE_CLASS DLLEXPORT The second option would be to leave the #include <windows.h> in tclWinPort.h and just #define TCHAR for ourselves in tclPlatDecls.h. Index: generic/tclPlatDecls.h =================================================================== RCS file: /cvsroot/tcl/tcl/generic/tclPlatDecls.h,v retrieving revision 1.6 diff -u -r1.6 tclPlatDecls.h --- generic/tclPlatDecls.h2000/08/20 03:51:231.6 +++ generic/tclPlatDecls.h2001/07/18 07:50:42 @@ -13,13 +13,17 @@ #define _TCLPLATDECLS /* - * Pull in the definition of TCHAR. Hopefully the compile flags - * of the core are matching against your project build for these - * public functions. BE AWARE. + * Define TCHAR without pulling in <windows.h>. If the + * core uses unicode but an extension does not, a compile + * time error should be generated. BE AWARE. */ -#if defined(__WIN32__) && !defined(_INC_TCHAR) -#include <tchar.h> -#endif +#ifdef __WIN32__ +#ifdef UNICODE +#define TCHAR wchar_t +#else +#define TCHAR char +#endif /* UNICODE */ +#endif /* __WIN32__ */ /* !BEGIN!: Do not edit below this line. */ @@ -96,6 +100,10 @@ #ifdef __cplusplus } #endif + +#ifdef __WIN32__ +#undef TCHAR +#endif /* __WIN32__ */ #if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) Comments? Does one seem better than the other?
hobbsplain2001-07-19 11:57:33
Logged In: YES user_id=72656 These are only includes we are talking about, so I'm not so sure that we should be using these verbose #define checks instead of just including what we know works in the end (like windows.h). Checking on things like _INC_TCHAR seems like an unnecessarily fragile thing to do. Also, we should keep the patches to the upload bit, because the comment area doesn't maintain plain text formatting. I'm for whatever it guaranteed to be correct for VC++ and cygwin without unneeded complexity in #def checks.
mdejongplain2001-07-19 14:04:31
Logged In: YES user_id=90858 Ok, I went ahead and checked in the version that pulled in <windows.h> in tclPlatDecls.h. Things now compile with VC++, mingw, and cygwin (minus the CreateThread changes).
Log in (anonymous is fine) to add a comment.
Attachments:
- patch3.txt [download] added by davygrvy on 2001-07-18 07:28:03. [details]
- patch [download] added by mdejong on 2001-07-18 05:11:52. [details]