Reputation: 1483
I'm drowning in the sea of casts between char*
and unsigned char*
, it's just ridiculous. There has to be some way around this.
Upvotes: 1
Views: 1461
Reputation: 36802
No. C++ pointers are more strongly typed than C's. You are required to cast between pointer types outside of upcasting in C++ which can happen implicitly. What you want is intentionally difficult in C++ to discourage people from doing so.
C allows these potentially unsafe conversions to occur silently, but if you enable warnings in gcc, the issues will be brought to your attention.
On another note: having a char *
point to an unsigned char
is well defined behavior, though could be error prone in the long run depending on how the memory is used.
Upvotes: 0