Register
Handmade Hero»Forums»Code»C++ as C
119 posts

Code hacker/developer

C++ as C
6 months, 4 weeks ago Edited by Todd on May 10, 2019, 1:57 p.m. Reason: Initial post
Casey seems to basically write C but compile with C++. I want to do that same to access a few C++ features such as the std::string library (I have to work with strings a lot and that sucks in C), references, and perhaps a few others. Is there any particular gotchas I need to know about doing this? For example, if I continue to use printf and all of the other C functions rather than cin and cout and etc.... Is this "bad" or can I do that just fine? Any other tips?

I'm the smartest man in Athens because I know that I know nothing. ~ Socrates
475 posts
C++ as C
6 months, 4 weeks ago
You can use whatever subset of C++ you feel comfortable with.

The only cost you'll need to worry about will be people complaining about your code.
119 posts

Code hacker/developer

C++ as C
6 months, 4 weeks ago
ratchetfreak
The only cost you'll need to worry about will be people complaining about your code.


Gotta love those people. Luckily, they'll likely never see my code anyway since the other team members also blend C and C++, favoring C. I guess I lucked out with finding a good situation to that end.

I'm the smartest man in Athens because I know that I know nothing. ~ Socrates
Miles
35 posts / 2 projects
C++ as C
6 months, 4 weeks ago
The major things to watch out for, in my opinion, are that 1. interactions between RAII types (like std::string) and C-style code and containers which expect everything to be a POD struct can be a minefield, and 2. certain C++ language and standard library features have a significant impact on compile times, debug performance, and code size - but you probably already knew as much.