Re:C will never stop you from making mistakes
by scruple on Monday August 10, 2020 @09:49AM
(#24109180)
I'd like to know, too. Have never seen either in practice.
[ Parent
| on HN ]
Re:C will never stop you from making mistakes
by flohofwoe on Monday August 10, 2020 @10:11AM
(#24109418)
The "pointless" cast is required for libraries that are written in the common subset of C and C++ so that they can be compiled both in a C or C++ compiler.
Some people prefer to compile C code through a C++ compiler for various reasons, Microsoft has even been recommending this because their C++ compiler isn't quite as terribly outdated as their C compiler:
https://herbsutter.com/2012/05/03/reader-qa-what-about-vc-an...
(not that I agree with the reasons, but for a library it makes sense to not lock out people who prefer to compile C libraries as C++ when integrated into a C++ project).