One of the most annoying things about C++ is the incompatibility with C's void *
conversion. In C, void *
can be cast implicitly to any pointer type, but C++ needs an explicit cast.
Most C code is valid C++ code, but the most common issue is malloc
, which returns void *
.
For example, this is valid C code, but not valid C++ code:
struct Foo *x = malloc(sizeof(struct Foo));
C++ needs an explicit cast, which gets verbose.
struct Foo *x = (struct Foo *)malloc(sizeof(struct Foo));
This uses the VoidPtr
class, which is typedefed to void *
in C. Use it in place of it.
Include this header and enjoy.
THANK YOU!!!!