CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: L macro

  1. #1
    George2 is offline Elite Member Power Poster
    Join Date
    Oct 2002
    Posts
    4,468

    L macro

    Hello everyone,


    I am using Visual Studio 2003 and Windows Console project, I find when using L macro to convert character to wide character, the compiler will report an error that L macro is not defined.

    I find it is not defined in either <windows.h> or <TCHAR.h> -- when adding the two header files, the compile error is the same.

    Could anyone explain how to use L macro in Visual Studio 2003 and Windows Console project? Which header file is needed?


    thanks in advance,
    George

  2. #2
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,725

    Re: L macro

    1) I don't think there is an "L macro". I think it is merely designates
    a wide character or a string literal made up of wide characters.

    2) an example:

    Code:
    #include <string>
    #include <iostream>
    
    using namespace std;
    
    int main (int argc, char** argv)
    {
        wstring w = L"Hello";
    
        wcout << w << L'\n';
    
        return 0;
    }

  3. #3
    Join Date
    Feb 2007
    Posts
    141

    Re: L macro

    Quote Originally Posted by Philip Nicoletti
    1) I don't think there is an "L macro". I think it is merely designates
    a wide character or a string literal made up of wide characters.

    2) an example:

    Code:
    #include <string>
    #include <iostream>
    
    using namespace std;
    
    int main (int argc, char** argv)
    {
        wstring w = L"Hello";
    
        wcout << w << L'\n';
    
        return 0;
    }
    New term for me wcout and wstring,
    Philip brother can you explain it to me what's the importance of using wcout and wstring

  4. #4
    Join Date
    Sep 2005
    Location
    New Delhi, India
    Posts
    332

    Re: L macro

    wcout - The object controls insertions to the standard output as a wide stream.
    wstring - A type that describes a specialization of the template class basic_string with elements of type wchar_t.
    Appreciate others by rating good posts

    "Only buy something that you'd be perfectly happy to hold if the market shut down for 10 years." - Warren Buffett

  5. #5
    George2 is offline Elite Member Power Poster
    Join Date
    Oct 2002
    Posts
    4,468

    Re: L macro

    Thanks Philip,


    If L is not a macro, what is it?

    I find my previous fault is I am compiling a C file (.c) and when I rename the file to .cpp, it could compile.


    regards,
    George

    Quote Originally Posted by Philip Nicoletti
    1) I don't think there is an "L macro". I think it is merely designates
    a wide character or a string literal made up of wide characters.

    2) an example:

    Code:
    #include <string>
    #include <iostream>
    
    using namespace std;
    
    int main (int argc, char** argv)
    {
        wstring w = L"Hello";
    
        wcout << w << L'\n';
    
        return 0;
    }

  6. #6
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: L macro

    If L is not a macro, what is it?
    It's part of the definition and syntax of the language. It's no different (in principle) from use of "F" at the end of a number to indicate a float, or "0x" at the beginning of a number to indicate a hex number.

    Mike

  7. #7
    George2 is offline Elite Member Power Poster
    Join Date
    Oct 2002
    Posts
    4,468

    Re: L macro

    Thanks Mike,


    Quote Originally Posted by MikeAThon
    It's part of the definition and syntax of the language. It's no different (in principle) from use of "F" at the end of a number to indicate a float, or "0x" at the beginning of a number to indicate a hex number.

    Mike
    I want to confirm that L can only be used in C++ and can not be used in C?


    regards,
    George

  8. #8
    Join Date
    Feb 2005
    Location
    "The Capital"
    Posts
    5,306

  9. #9
    George2 is offline Elite Member Power Poster
    Join Date
    Oct 2002
    Posts
    4,468

    Re: L macro

    Thanks exterminator,


    Quote Originally Posted by exterminator
    Valid for both!
    I have tried that it works for both. It is my careless fault before.


    regards,
    George

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured