I know there are differences in the source code between C and C++ programs – this is not what I’m asking about.
I also know this will vary from CPU to CPU and OS to OS, depending on compiler.
I’m teaching myself C++ and I’ve seen numerous references to libraries that can be used by both languages. This has started me thinking – are there significant differences between the binary executables of the two languages?
For libraries to be easily used by both, I would think they’d have to be similar on an executable level.
Are there many situations where a person could examine a executable file and tell whether it was created by C or C++ source code? Or would the binaries be pretty similar?
In most cases, yes, it’s pretty easy. Here are just a few clues that I’ve seen often enough to remember them easily:
thispointer into C++ member functions. Again, since thethispointer simply doesn’t exist in C, you’ll rarely see a direct analog (though in some cases, they will use the same convention to pass some other pointer, so you need to be careful about this one).