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 From: "Lothan" To: "Cygwin" Subject: RE: misdefined macro _T in winnt.h Date: Mon, 5 Feb 2001 22:08:28 -0800 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 In-Reply-To: <3A79EED1.94E903E7@yahoo.com> Importance: Normal I suppose we might consider this the definitive answer. I pasted in this source code: #define __DIR "dir" #define _UNICODE #include #include main() { size_t len = wcslen(_T(__DIR)) + wcslen(_T("dir")); size_t len2 = wcslen(_TEXT(__DIR)) + wcslen(_TEXT("dir")); exit(len); } I ran it through the preprocessor for both Borland C++ 5.0 and Microsoft Visual C++ 6.0 and got identical output from both preprocessors. main() { size_t len = wcslen(L"dir") + wcslen(L"dir"); size_t len2 = wcslen(L"dir") + wcslen(L"dir"); exit(len); } I get this output from gcc: main() { size_t len = wcslen(L__DIR ) + wcslen(L"dir" ); size_t len2 = wcslen(L__DIR ) + wcslen(L"dir" ); exit(len); } In my opinion, the output from Borland C++ and MSVC is correct. The output from gcc is dead wrong. Not surprisingly, the declarations are also identical for Borland C++ and MSVC: #define _T(x) __T(x) #define _TEXT(x) __T(x) #define __T(x) L ## x The relevant declarations from gcc are: #define _TEXT(x) L ## x #define _T(x) L ## x If you replace the erroneous definitions in tchar.h with the correct definitions from above, it parses correctly. > > > #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")? > > > > No. I'm certain of that, more or less ... > > > > 1) If that is true then what is the purpose of function L()? > 2) Can someone who has MSVC++ tell me what the _T(__dir) expands to > using the above example? > 3) Is it legal to pass a MACRO as an argument to the _T() macro? > > 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 > -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple