I’m not sure what programming in C really means:
– Programming in pure C with a C compiler
or
– programming in C with a C++ compiler.
Apart from the differences between the C’s syntax of C and the C’s syntax of C++, can I safely say there are absolutely (or in very few cases) no differences between two executables in terms of performance ?
I’m thinking about this issue, because in game programming, each one of the rendering part, the game object part and the game scripting part can be programmed completely different languages, to obtain the best compromise between execution speed and easy development, and this at each one of those part.
This separation between parts can be important for me, for example, I want to make a versatile 3D adventure engine, where a community would make their own gameplay without having to mess with the engine. It would only be able to make games with a single character and several ennemies, so different game type would be covered: hack & slash, infiltration, RPG, platform, etc.
I should have put this 2 paragraphs in gamedev.stackexchange, but the first part is only about languages…
There are a lot of minor nitpicks. One that strikes me as being the most obvious is that in C++, you have to cast the return value of
malloc. Also structs are automatically typedefed in C++.Always use a C compiler for C code, not C++. C++ isn’t perfectly compatible with C.
A few others:
void func();declares a function that hasn’t specifed what its arguments are, whereas in C++,void func();is equivalent to the Cvoid func(void)', taking no arguments;'a') isintin C andcharin C++;char []in C andconst char []in C++;class, are reserved keywords in C++.For all those who don’t believe me and are downvoting, check out this C code:
Compilation under
gccis fine, but compilation underg++gives the following errors: