Thread: What is '_T' ?

  1. #1
    Registered User
    Join Date
    Nov 2015
    Posts
    112

    What is '_T' ?

    Kind all day and night! My belated congratulations to you, with the May holidays, a joyful way out into the forest and barbecue with friends and families. With a day of memory, a holiday of the greatest victory, I also congratulate. Laying flowers and a glass of vodka to fallen heroes.


    What is '_T' ?? Can not understand. Twenty minutes google.com with no result. What is this?
    Last edited by Dmy; 05-11-2017 at 04:24 AM.

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,731
    Remember kids, don't post in forums while intoxicated.

    '_T' turns your string literal into a Unicode literal if you're compiling with unicode support. I don't know whether it's a standard macro or specific to any platform or compiler. For example:
    Code:
    _T("whatever") becomes:
    L"whatever" // if you support unicode
    "whatever" // if you don't
    Devoted my life to programming...

  3. #3
    Registered User
    Join Date
    Nov 2015
    Posts
    112
    Thank you!!!!!!!
    And in what includa is located?

  4. #4
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,731
    I would guess in <windows.h>, but I don't really know.
    Devoted my life to programming...

  5. #5
    Registered User
    Join Date
    Nov 2015
    Posts
    112
    I guess I do not see any error.

    Code:
    // TestDLL.cpp : Defines the entry point for the console application.
    //
    
    #include "windows.h"
    #include "iostream"
    #include "support.h"
    
    int main()
    {
        HINSTANCE hModule=NULL;
        typedef  BOOL (WINAPI MESS)(UINT);
        MESS* me=NULL;
        hModule=::LoadLibrary(_T("user32.dll"));
        if (hModule!=NULL)
        {
            me=(MESS*)::GetProcAddress((HMODULE)hModule,"MessageBeep");
            if (me!=NULL)
            {
                UINT type=1;
                BOOL result;
                result=(*me)(type);
            }
            else std::cout << "Error Load function" << std::endl;
            ::FreeLibrary(hModule);
        }
        else std::cout << "error load Dll" << std::endl;
    
    return 0;
    }
    D:\DLL\D1\D1.cpp|13|error: '_T' was not declared in this scope|
    Last edited by Dmy; 05-11-2017 at 05:19 AM.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,170
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Jun 2015
    Posts
    1,643
    A simplified example of what's going on.
    Code:
    #include <stdio.h>
    
    #ifdef _UNICODE
    #  include <wchar.h>
    #  define _T(s)  L##s
    #  define tprintf wprintf
    #else
    #  define _T(s)  s
    #  define tprintf printf
    #endif
    
    int main() {
        tprintf(_T("hello\n"));
        return 0;
    }

  8. #8
    Registered User MacNilly's Avatar
    Join Date
    Oct 2005
    Location
    CA, USA
    Posts
    466
    The correct answer is ... "I have no idea, unless you provide a context".

    [EDIT]

    Oh, how gross...

  9. #9
    Registered User MacNilly's Avatar
    Join Date
    Oct 2005
    Location
    CA, USA
    Posts
    466
    Code:
    #include "windows.h"
    #include "iostream"
    #include "support.h"
    That's just wrong.

    [EDIT]

    Actually that code is just wrong. Horrid.

    Is that real code? Jesus
    Last edited by MacNilly; 05-13-2017 at 07:00 AM.

Popular pages Recent additions subscribe to a feed

Tags for this Thread