Portability of C++ Compared to C

Started by
12 comments, last by LorenzoGatti 12 years, 3 months ago
Portability goes out the window very quickly, as you almost always have to work with a platform-specific API to implement anything useful.

Choosing what platforms you want to support should come first. From there, you can propose a strategy to meet those requirements.
Advertisement

Neither C nor C++ has a standard ABI last time I checked.The C++ language standard strictly defines semantics of all language constructs. However, it does not specify how these constructs must be implemented at binary level (in object code). As there is no common application binary interface (ABI) standard, C++ compiler vendors have come up their own ABI variations. As a result, problems can arise when object files produced by different compilers are linked together. These problems are usually caused either by the differences in memory layout of compiler-generated data structures, different calling conventions, or differences in name mangling. The main differences of an EABI with respect to an ABI for general purpose operating systems are that privileged instructions are allowed in application code, dynamic linking is not required (sometimes it is completely disallowed), and a more compact stack frame organization is used to save memory.
I remember Stroustroup for example talking about how recursion wasn't allowed on development of JSF.
Another example iPhone. Although garbage collection with Objective-C is fully supported on Mac OS X it isn't on iOS although they now have ARC I believe.

ABI conventions come into play when we are starting to look at generated code, as opposed to pure source code. ABI rarely affect your ability to write higher level code, so I'm not sure why anyone would be too concerned about it. The most impact it had in my experience is passing function pointers around and declaring functions with variadic argument lists. In those cases you are forced to disable any language/platform extensions for those particular functions, such as fastcall, etc.
Latest project: Sideways Racing on the iPad
Just to throw this out there, Android only recently received STL, RTTI, and Exception support. Many embedded systems don't include support for these 3 things off the bat, and many never get them at all.
Co-founder/Lead Programmer
Bonafide Software, L.L.C.
Fairmont, WV 26554 US

Just to throw this out there, Android only recently received STL, RTTI, and Exception support.

You don't mean Android, you mean a C++ compiler for Android. Which one are you referring to?

Omae Wa Mou Shindeiru

This topic is closed to new replies.

Advertisement