简体   繁体   English

VS2017 C ++编译器错误C2664无法转换参数

[英]VS2017 C++ compiler error C2664 can not convert argument

Using VS2017 I compile the code below using the unicode character set 使用VS2017,我使用Unicode字符集编译以下代码

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. VS2008下的相同代码可以很好地编译。 What seems to be to problem here and why the compiler chooses the ANSI version of the PathFindExtenstion instead of the unicode one ? 这里似乎有什么问题,为什么编译器选择ANSI版本的PathFindExtenstion而不是unicode版本?

The problem was that the VS2017 variable 问题是VS2017变量

%(PreprocessorDefinitions) %(PreprocessorDefinitions)

was missing from Preprocessor Definitions . 预处理程序定义中丢失。 Now the definers /D _UNICODE and /D UNICODE are added correctly to the compiler parameter's list. 现在,定义器/ D _UNICODE/ D UNICODE已正确添加到编译器参数的列表中。

缺少%(PreprocessorDefinitions)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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