2 Replies - 6004 Views - Last Post: 22 April 2008 - 03:15 AM Rate Topic: -----

#1 tinuchirag  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 21-April 08

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

Posted 21 April 2008 - 10:47 PM

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
}

Is This A Good Question/Topic? 0
  • +

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

#2 skaoth  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 91
  • View blog
  • Posts: 601
  • Joined: 07-November 07

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

This post has been edited by skaoth: 22 April 2008 - 12:06 AM

Was This Post Helpful? 0
  • +
  • -

#3 tinuchirag  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 21-April 08

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

Posted 22 April 2008 - 03:15 AM

View Postskaoth, 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



Thank you skaoath.......... :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1