I would like to know if you have some links to guidelines to migrating from C to C++.
I'm mainly interested in the constructions to check in the C code that could have problems the compiler can not detect? And what are the workarounds?
Note: Please don't answer with things the compiler is able to detect.
One way to investigate this is just to read through some lists of incompatibilities between C and C++, and see which ones produce run-time issues rather than compilation issues. Such lists are plentiful, good starting places might be:
Do you mean learning C++ assuming knowing C? Or do you mean translating a C project to C++? If the latter, and if the project is of any significance size, I'd say don't do it. If the project has any momentum then it's suicide; it's a waste of time, effort, motivation and good spirit.
The first two editions of Effective C++ focuses on C programmers coming to C++ running into a lot of pitfalls. I'd say go for Edition 2 of Effective C++ (its basically a rework of first edition).
Maybe my answer is invalid as there actually are a Effective C++ flag for GCC. Also with modern warnings for strict aliasing etc etc you are pretty close to perfect C++ if you get everything to compile with really all warnings enabled.
You must unlearn what you have learned.
And more seriously -- the biggest mistake of teaching C++ is teaching it as a superset of C. C and C++ are two different languages with different approaches to solving problems. The syntax may be very similar, but the approach differs. And while most valid C programs are valid C++, this is just a side effect of building C++ on top of C.
Recompiling a C project with a C++ compiler doesn't make the project C++.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With