简体   繁体   English

在字符错误 C2440 中转换 LPVOID:=

[英]convert LPVOID IN CHAR ERROR C2440: =

How do I convert a LPVOID to char ?如何将 LPVOID 转换为 char ?

char * pCacheMap;

pCacheMap = MapViewOfFile(hCacheMapping,FILE_MAP_READ|FILE_MAP_WRITE,0,0,0);

Error:错误:

    3   IntelliSense: a value of type "LPVOID" cannot be assigned to an entity of type "char *" 
Error   1   error C2440: '=' : cannot convert from 'LPVOID' to 'char *' 

Use a cast.使用演员表。 Since LPVOID is a synonym for void * it is legal to cast it to any other pointer type so:由于 LPVOID 是 void * 的同义词,因此将其强制转换为任何其他指针类型是合法的,因此:

pCacheMap = static_cast<char *>(MapViewOfFile(...)); 

will work.将工作。

暂无
暂无

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

相关问题 错误C2440:“正在初始化”:无法从“ LPVOID”转换为“ UINT” - error C2440: 'initializing' : cannot convert from 'LPVOID' to 'UINT 错误C2440:'=':无法从'const char [2]'转换为'char' - error C2440: '=' : cannot convert from 'const char [2]' to 'char' 错误C2440:&#39;=&#39;:无法从&#39;char [5]&#39;转换为&#39;char [20]&#39; - error C2440: '=' : cannot convert from 'char [5]' to 'char [20]' 错误C2440:“ =”:无法从“ int”转换为“ char [5]” - error C2440: '=' : cannot convert from 'int' to 'char [5]' 错误C2440:将char [] *转换为char *(指针) - error C2440: char[]* to char* (pointers) C2440:“ =”:无法从“ const char [9]”转换为“ char *” - C2440: '=': cannot convert from 'const char [9]' to 'char*' 错误C2440:&#39;=&#39;:无法从&#39;char *(__ cdecl *)(int,int)&#39;转换为en&#39;GetItemText_t&#39; - error C2440: '=' : cannot convert from 'char *(__cdecl *)(int,int)' to en 'GetItemText_t' 错误C2440:&#39;初始化&#39;:无法从&#39;初始化列表&#39;转换为&#39;std :: vector <char *,std::allocator<_Ty> &gt;” - error C2440: 'initializing': cannot convert from 'initializer list' to 'std::vector<char *,std::allocator<_Ty>>' 智能感知:错误C2440:&#39;=&#39;:无法从&#39;unsigned long(__stdcall *)(const char *)&#39;转换为&#39;IPAddr&#39; - Intellisense: error C2440: '=' : cannot convert from 'unsigned long (__stdcall *)(const char *)' to 'IPAddr' 错误 C2440:“正在初始化”:无法从“const char *”转换为“TCHAR *” - error C2440: 'initializing': cannot convert from 'const char *' to 'TCHAR *'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM