简体   繁体   中英

VS2017 C++ compiler error C2664 can not convert argument

Using VS2017 I compile the code below using the unicode character set

STDMETHODIMP Load(LPCOLESTR lpwszFileName, const AM_MEDIA_TYPE *pmt) {
 TCHAR *szExtension = PathFindExtension(lpwszFileName);

and I get the following error

error C2664: 'LPSTR PathFindExtensionA(LPCSTR)': cannot convert argument 1 from 'LPCOLESTR' to 'LPCSTR'

The same code under VS2008 compiles just fine. What seems to be to problem here and why the compiler chooses the ANSI version of the PathFindExtenstion instead of the unicode one ?

The problem was that the VS2017 variable

%(PreprocessorDefinitions)

was missing from Preprocessor Definitions . Now the definers /D _UNICODE and /D UNICODE are added correctly to the compiler parameter's list.

缺少%(PreprocessorDefinitions)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM