VS2022, no overloaded function instance matching parameter list when writing C/C++

When I was learning C/C++, when I used EasyX to build a graphical interface, I encountered an error that there was no function instance matching the parameter list. The error code E0304 was obtained after inquiring and collecting information. The reason for the error is because the actual storage of the string is too large. An encoding format. If the default encoding format does not match the actual execution platform, an error will occur. Solution 1: Modify all strings to TCHAR version. Simply put, you need to pay attention to the following points: Use #include in the program to add support for TCHAR.

 

After asking and collecting information, we got the following
error reason
: The actual storage of strings has multiple encoding formats. If the default encoding format does not match the actual execution platform, an error will occur.
Solution
Method 1: Modify all strings to the TCHAR version.
Simply put, you need to pay attention to the following points:

  1. Use #include in your program to add support for TCHAR.
  2. For strings, such as "abc", use _T("abc"). Just add _T("").
  3. When defining character variables, replace char with TCHAR.
  4. Functions that operate on strings must also be replaced with the corresponding TCHAR version.
    Method 2: Cancel the Unicode encoding macro definition in the code, so that subsequent compilation will be performed in MBCS encoding.
    The method is very simple. You only need to add the following code at the top of the code:
    #undef UNICODE
    #undef _UNICODE
    . This will cancel the Unicode encoding macro definition and allow the entire project to be compiled with MBCS encoding.
    Method 3: Taking VS2019 as an example, just right-click the project>Properties>Configuration Properties>Advanced, and change the character set
    in the advanced properties to use a multi-byte character set

Guess you like

Origin blog.csdn.net/lxyhhhhhcl/article/details/131470927