Thursday, February 11, 2021

Error (active) E0167 argument of type "const char *" is incompatible with parameter of type "LPCWSTR"

Error (active) E0167 argument of type "const char *" is incompatible with parameter of type "LPCWSTR" Test04 C:\Demo_GLUT\Test04\Test04.cpp 464

  1. argument of type const char* is incompatible with parameter of type “LPCWSTR”
  2. I am trying to make a simple Message Box in C in Visual Studio 2012, but I am getting the following error messages

    argument of type const char* is incompatible with parameter of type "LPCWSTR"
    error LNK2019:unresolved external symbol_main referenced in function_tmainCRTStartup

    A Solution: Check your project's Character Set setting (Project Properties, Configuration Properties, General, Character Set). It's probably set to "Use Unicode" instead of "Use Multi-Byte".

    To make your code compile in both modes, enclose the strings in _T() and use the TCHAR equivalents
    #include < tchar.h >
    #include < windows.h >
    int WINAPI _tWinMain(HINSTANCE hinstance, HINSTANCE hPrevinstance, LPTSTR lpszCmdLine, int nCmdShow)
    {
    MessageBox(0,_T("Hello"),_T("Title"),0);
    return 0;
    }

    A Solution: I recently ran in to this issue and did some research and thought I would document some of what I found here.

    To start, when calling MessageBox(...), you are really just calling a macro (for backwards compatibility reasons) that is calling either MessageBoxA(...) for ANSI encoding or MessageBoxW(...) for Unicode encoding.

  3. ConstChar Error, Coding/Gaming
  4. ERROR 1 NAME : argument of type "WCHAR" is incompatible with parameter of type "const char*"

    ERROR 2 NAME : argument of type "const char*" is incompatible with parameter of type "LPCWSTR"

  5. This is a paragraph.

  6. This is a paragraph.

  7. This is a paragraph.

  8. This is a paragraph.

  9. This is a paragraph.

  10. This is a paragraph.

  11. This is a paragraph.

  12. This is a paragraph.

  13. This is a paragraph.

  14. This is a paragraph.

  15. This is a paragraph.

  16. This is a paragraph.

  17. This is a paragraph.

  18. This is a paragraph.

  19. This is a paragraph.

  20. This is a paragraph.

No comments:

Post a Comment