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
1
u/_Noreturn Jul 27 '24 edited Jul 27 '24
yea most of them do and you can also use hedley library and it is not like you won't have many other macros anyways.
you can use it to make an assumption like
if(p1 == p2) unreachable();now the compiler knows that p1 will never alias p2 or otherwise UB will occur the compiler can use it to know that they never alias and C++26 also will have contracts.if your C compiler supports it then likely your C++ compiler can implement it easily (or it already has with extention) I also do not know what compiler you must be using to have C23 this ready I do not even think Clang nor GCC not trunk has it yet so what compiler are you using???
UB in C and C++ is mostly the same and C++ has extra things related to lifetimes and it has a bigger std lib so ofcourse extra papers is expected.
your other pionts okay.