Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,076 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,596 people online right now. Registration is fast and FREE... Join Now!




error C2440: '=' : cannot convert from 'const char (*)[8]&

 
Reply to this topicStart new topic

error C2440: '=' : cannot convert from 'const char (*)[8]&

tinuchirag
21 Apr, 2008 - 09:47 PM
Post #1

New D.I.C Head
*

Joined: 21 Apr, 2008
Posts: 2

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
}
User is offlineProfile CardPM
+Quote Post

skaoth
RE: Error C2440: '=' : Cannot Convert From 'const Char (*)[8]&
21 Apr, 2008 - 11:05 PM
Post #2

D.I.C Regular
Group Icon

Joined: 7 Nov, 2007
Posts: 342



Thanked: 10 times
Dream Kudos: 100
My Contributions
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

This post has been edited by skaoth: 21 Apr, 2008 - 11:06 PM
User is online!Profile CardPM
+Quote Post

tinuchirag
RE: Error C2440: '=' : Cannot Convert From 'const Char (*)[8]&
22 Apr, 2008 - 02:15 AM
Post #3

New D.I.C Head
*

Joined: 21 Apr, 2008
Posts: 2

QUOTE(skaoth @ 22 Apr, 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



Thank you skaoath.......... biggrin.gif
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 07:27PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month