2 ms·
> If your C code happens to be compileable with a C++ compiler, then either your program is very small or you are writing really shitty C. It is easy to write
by attractivechaos 6y ago
> If your C code happens to be compileable with a C++ compiler, then either your program is very small or you are writing really shitty C.
It is easy to write C code that is compatible with C++ if you have compatibility in mind from the beginning. Most of time: 1) cast malloc() – you can define macros for less code; 2) avoid C++ keywords; 3) don't use VLA which is not recommended anyway; 4) add __STDC_LIMIT_MACROS for uint64_t etc. Use -Wc++-compat also helps. It is harder to modify existing C code for the compatibility with C++.