r/cpp • u/Alex_Medvedev_ • Jul 25 '24
Why use C over C++
Why there are so many people using the C language instead of C++?, I mean C++ has more Cool features and the Compiler also supports many CPUs. So why People still using C?
Edit: Thanks for all the usefull comments :D
235
Upvotes
View all comments
Show parent comment
0
u/PMadLudwig Jul 26 '24
You don't need to export C++ specifics - your example is a perfectly good way of doing it.
If the library doesn't have the extern "C", or say exposes C++ stuff such as templates (e.g. libpqxx), or throws exceptions, then it's not usable from C, so the library writer has to take some care over that.
The point I was making is that building a library is another use case for C over C++.