Error [Pe513]: value of type "void *" cannot be assigned to an entity of type "uint8_t *"

I am trying to convert a C project to C ++.

In project C, I contrasted this error when compiling in C ++:

Error [Pe513]: value of type "void *" cannot be assigned to an entity of type "uint8_t *"

The following code gives this error:

#define RAM32Boundary  0x20007D00
uint8_t *pNextRam;
pNextRam = (void*)RAM32Boundary;// load up the base ram

Can anyone explain what this does in C and how to convert it to C ++?

+5
source share
1 answer

C allows implicit conversions to / from void*, which C ++ does not. You need to specify the correct type.

Using:

uint8_t *pNextRam;
pNextRam = (uint8_t*)RAM32Boundary;// load up the base ram

Or best of all * , use the C ++ style instead of the C style .:

uint8_t *pNextRam;
pNextRam = static_cast<uint8_t*>(RAM32Boundary);// load up the base ram

* . ++ .

+15

All Articles