3 ms·
I'm not sure about other compilers, but compiling C code as C++ with MSVC ends up with pretty much the exact same code, instruction by instruction. C++ is a bit
by neonz80 1y ago
I'm not sure about other compilers, but compiling C code as C++ with MSVC ends up with pretty much the exact same code, instruction by instruction. C++ is a bit more strict though especially with casting, so a lot of code won't compile out of the box.
- vbezhenar 1y agoC++ code compiles to a different function names in object file (name mangling). You probably need to put a lot of ugly `#ifdef __cplusplus extern "C" {` boilerplate in your headers, otherwise C and C++ files will not compile together.
- winocm 1y agoDon't forget the infamous pattern used in some C projects too: struct foo decl = { .member = /* ... */ .next = &(struct nested_pointer) { .nested_member = /* ... */, }, .array = (struct nested_array[]) { [0] = { /* ... */ }, } }; This pattern does not work in C++ as the nested declarations become temporaries.