error C3861: '_L': identifier not found in VS2008 only. (works ok in VC6)
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: error C3861: '_L': identifier not found in VS2008 only. (works ok in VC6)

  1. #1
    Join Date
    Dec 1999
    Posts
    83

    error C3861: '_L': identifier not found in VS2008 only. (works ok in VC6)

    I'm converting a working unicode app dll from vc6 to vs2008, but I'm getting a compile error: '_L': identifier not found

    example line of code:-

    if(*strPrinter==_L(""))


    The program already includes: #include <AtlConv.h>

    I have tried adding #include <wchar.h> and <tchar.h> to no avail.

    NOTE: this is working on VS6, so maybe it's a problem with project settings somewhere??? any ideas?

    Thanks,
    Hobnob

  2. #2
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,235

    Re: error C3861: '_L': identifier not found in VS2008 only. (works ok in VC6)

    Are you getting mixed up with _T() ?? Assuming that *strPrinter can either be Unicode or non-Unicode (depending on the compilation) I think the syntax should be:-

    Code:
    if (*strPrinter == _T(""))
    "A problem well stated is a problem half solved. - Charles F. Kettering

  3. #3
    Join Date
    Dec 1999
    Posts
    83

    Re: error C3861: '_L': identifier not found in VS2008 only. (works ok in VC6)

    ok, worked it out... maybe my example wasn't clear enough, anyway:-

    CStringW strLicenseKey = _L("TEXT HERE");

    should be:- (to work on 2008)

    CStringW strLicenseKey = L"INSERT_LICENSE_KEY_HERE";

  4. #4
    Join Date
    Dec 1999
    Posts
    83

    Re: error C3861: '_L': identifier not found in VS2008 only. (works ok in VC6)

    ok, worked it out... maybe my example wasn't clear enough, anyway:-

    CStringW strLicenseKey = _L("TEXT HERE");

    should be:- (to work on 2008)

    CStringW strLicenseKey = L"TEXT HERE";

  5. #5
    Join Date
    Apr 1999
    Posts
    27,422

    Re: error C3861: '_L': identifier not found in VS2008 only. (works ok in VC6)

    Quote Originally Posted by hobnob View Post
    should be:- (to work on 2008)

    CStringW strLicenseKey = L"INSERT_LICENSE_KEY_HERE";
    The correct way is to use
    Code:
    CStringW strLicenseKey = L"INSERT_LICENSE_KEY_HERE";
    regardless of the compiler. So it isn't just to get it to work on 2008 -- you need to do this for any ANSI C++ compiler, let alone Visual C++.

    I have never heard of the "_L" macro, but if it is a macro, take a look at the definition of what "_L()" is.

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; November 18th, 2012 at 06:46 PM.

  6. #6
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,923

    Re: error C3861: '_L': identifier not found in VS2008 only. (works ok in VC6)

    Quote Originally Posted by hobnob View Post
    ok, worked it out... maybe my example wasn't clear enough, anyway:-

    CStringW strLicenseKey = _L("TEXT HERE");

    should be:- (to work on 2008)

    CStringW strLicenseKey = L"TEXT HERE";
    First, VC6 knows nothing about CStringW, as this type was introduced in VC7.

    Second, a simple experiment:
    Code:
    #include <afxwin.h>
    
    void foo ()
    {
    	CString str = _L("Bla-bla");
    }
    Code:
    E:\Temp\70>cl 70.cpp /D"_AFXDLL" /D"UNICODE" /D"_UNICODE" /MD /c
    Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
    Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
    
    70.cpp
    70.cpp(5) : error C2065: '_L' : undeclared identifier
    Best regards,
    Igor

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center