Join Now

Difference between the pointers in Carbide c++ and C++

Carbider | 17 October, 2007 16:11

One more difference between Carbide C++ and standard C++ that I found while porting is pointers maintaining.
If you have a pointer 'p'
void *p = other_pointer;
in C you can sum it up with integer value to walk through memory:
p += sizeof(uint8_t);
That is frequently used in BlueZ libraries.
But Carbide doesn't allow such manipulation motivating with:
"illegal operands 'void *' + 'unsigned int'"
That is because Carbide is more strict with types than C is.
So to move through memory I need that pointer 'p' would be a pointer to specific data type, not ‘void’.
I decided, 'p' should be a pointer to 'uint8_t' because it is used as type’s length to determine data’s displacement step.
So the final declaration looks like this:
uint8_t *p;;

p += sizeof(uint8_t);

 
 
Powered by LifeType