3 ms·
I don't quite follow. C will also prevent you from mixing up disparate pointer types; and c++ has no protection against void pointers.
by moonchild 6y ago
I don't quite follow. C will also prevent you from mixing up disparate pointer types; and c++ has no protection against void pointers.
- inetknght 6y ago> C will also prevent you from mixing up disparate pointer types No it won't. In C++ it's a compile error [0]. In C it's just a warning [1]. > c++ has no protection against void pointers You're somewhat correct but the answer is a lot more nuanced (because void* is very nuanced). Again, C++ will complain unless you do it "right" [2] while C is ... willing to let you blow your leg off [3]. However the definition of "right" is still just as dangerous as C's because all type information was lost in the void and it's up to the programmer to get it right -- and programmers are notoriously buggy. [0] https://gcc.godbolt.org/z/166ns8 https://gcc.godbolt.org/z/166ns8 [1] https://gcc.godbolt.org/z/vEnajj https://gcc.godbolt.org/z/vEnajj [2] https://gcc.godbolt.org/z/cGe39z https://gcc.godbolt.org/z/cGe39z [3] https://gcc.godbolt.org/z/orb1s8 https://gcc.godbolt.org/z/orb1s8
- int_19h 6y agoUsing extern "C" doesn't change the C++ rules for implicit pointer conversions, though.