Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com X-Apparently-From: Message-ID: <3A798D62.A9D8B309@yahoo.com> Date: Thu, 01 Feb 2001 11:22:58 -0500 From: Earnie Boyd Reply-To: Earnie Boyd X-Mailer: Mozilla 4.76 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 To: Eric Paire CC: Earnie Boyd , Eric PAIRE Subject: Re: misdefined macro _T in winnt.h References: <200102011244 DOT NAA06873 AT mailhost DOT ri DOT silicomp DOT fr> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Eric Paire wrote: > > Earnie Boyd wrote: > > > > Eric PAIRE wrote: > > > > > > Hi cygwin people, > > > > > > I have found a problem with the _T macro definition as it is defined in > > > w32api/include/winnt.h: "#define _T TEXT" does not compile correctly the > > > following small program: > > > > > > ------ Cut Here ------ Cut Here ------ Cut Here ------ Cut Here ------ > > > #include > > > #define __DIR "dir" > > > > > > main() { > > > size_t len = wcslen(_T(__DIR)) + wcslen(_T("dir")); > > > exit(len); > > > } > > > ------ Cut Here ------ Cut Here ------ Cut Here ------ Cut Here ------ > > > > > > > What problems do you see compiling this with the current headers? I'm > > not having problems compiling this example. > > > Sorry folks, I have forgotten to tell you to compile it with the _UNICODE > and UNICODE defined. Here is a corrected version that has some problems > when compiled: > > ------ Cut Here ------ Cut Here ------ Cut Here ------ Cut Here ------ > #define __DIR "dir" > > #include > #include > main() { > size_t len = wcslen(_T(__DIR)) + wcslen(_T("dir")); > size_t len = wcslen(_TEXT(__DIR)) + wcslen(_TEXT("dir")); > exit(len); > } > ------ Cut Here ------ Cut Here ------ Cut Here ------ Cut Here ------ > > You will see that the problem is around the evaluation of the __DIR macro > (there is no problem with "dir"), both for _TEXT and _T. In addition, this > should be fixed also for the _T and _TEXT definitions in , which > should be coherent with those in (They are not for now, as _T is > defined either as an object-like macro (in ) or as a function-like > macro (in )). > > If you want me to provide you with a patch (and a ChangeLog), let me know... > No, I don't need a patch. I do need to know if L"dir" == L("dir") ? The problem with this macro is the use of the macro concatenation ## and the order in which the macros are resolved. Currently we have #define _T(x) L ## x and if you pass a macro FOO as an argument to this macro you get LFOO returned and not the value of FOO appended to L. If I change this to #define _T(x) L(x) then I get returned L("bar") where "bar" is the value of FOO. This allows the program to compile but does L"bar" == L("bar")? Earnie. _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple