I am migrating my application from .net 2003 to .net 2005 which ahs some code related to RFID Reders in evc++. On complilng the given code I get following error:
error C2440: '=' : cannot convert from 'const char (*)[8]' to 'char *'
the place where i get this error is:
#define VER_PLATFORM_WIN32_CE 3
#define s_VER_PLATFORM_WIN32_CE "CE"
char* pVersion = NULL;
long PlatformID = VersionInformation.dwPlatformId;
switch (PlatformID) {
case VER_PLATFORM_WIN32_CE:
pVersion = &s_VER_PLATFORM_WIN32_CE; //error over here
break;
default:
pVersion = &s_VER_PLATFORM_UNKNOWN; //error over here
}
2 Replies - 5599 Views - Last Post: 22 April 2008 - 03:15 AM
#1
error C2440: '=' : cannot convert from 'const char (*)[8]&
Posted 21 April 2008 - 10:47 PM
Replies To: error C2440: '=' : cannot convert from 'const char (*)[8]&
#2
Re: error C2440: '=' : cannot convert from 'const char (*)[8]&
Posted 22 April 2008 - 12:05 AM
it looks like you are trying to treat a #define as a variable
pVersion = &s_VER_PLATFORM_WIN32_CE; //error over here
This is invalid. When the compiler sees s_VER_PLATFORM_WIN32_CE, what it will do is replace it with the value you specifed. In this clase it looks like the compiler is putting the value "CE" into a 8 byte character array. To fix it simply remove the '&' infront of s_VER_PLATFOR_WIN32_CE
pVersion = &s_VER_PLATFORM_WIN32_CE; //error over here
This is invalid. When the compiler sees s_VER_PLATFORM_WIN32_CE, what it will do is replace it with the value you specifed. In this clase it looks like the compiler is putting the value "CE" into a 8 byte character array. To fix it simply remove the '&' infront of s_VER_PLATFOR_WIN32_CE
This post has been edited by skaoth: 22 April 2008 - 12:06 AM
#3
Re: error C2440: '=' : cannot convert from 'const char (*)[8]&
Posted 22 April 2008 - 03:15 AM
skaoth, on 22 Apr, 2008 - 12:05 AM, said:
it looks like you are trying to treat a #define as a variable
pVersion = &s_VER_PLATFORM_WIN32_CE; //error over here
This is invalid. When the compiler sees s_VER_PLATFORM_WIN32_CE, what it will do is replace it with the value you specifed. In this clase it looks like the compiler is putting the value "CE" into a 8 byte character array. To fix it simply remove the '&' infront of s_VER_PLATFOR_WIN32_CE
pVersion = &s_VER_PLATFORM_WIN32_CE; //error over here
This is invalid. When the compiler sees s_VER_PLATFORM_WIN32_CE, what it will do is replace it with the value you specifed. In this clase it looks like the compiler is putting the value "CE" into a 8 byte character array. To fix it simply remove the '&' infront of s_VER_PLATFOR_WIN32_CE
Thank you skaoath..........
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|