I have a struct defined in a historical library with alas, an unfortunate choice of type: unsigned char * instead of char*.
struct MyStruct {
unsigned char * myMember;
};
This struct is used by a huge number of C applications and, more and more, by C++ applications. Those C++ applications raise an error when used with strlen, for example, forcing us to cast. Lots of casts.
I would like to remedy that.
But one thing is extremely important: it must be absolutely compatible without modification and have no impact on the existing projects.
I thought about making a union. Alas, my variable can't have the same name.
struct MyStruct {
union {
unsigned char * myMember;
// char * myMember; Obvioulsy, rejected by the compiler.
};
I'm afraid there isn't any obvious solution. Am I wrong?
I can't change the size of the struct because it's mapped in an unchangeable sized shared memory.