I also wrote code that was for use on all platforms, including Windows XP and Mobile. I've written portable code successfully in the past - I was working mostly on one platform for a particular product, using GCC. Or a MSVC stdint.h is easy enough to find or write. For instance, one which defines "inline" as "inline" on GCC and MSVC/C++, but "_inline" for MSVC/C. Otherwise you can write little "language abstraction" headers of your own. If all you care about is GCC and MSVC, you can switch on some language features you know MSVC has. Writing correct C89 is somewhat restrictive (no // comments, declarations must precede statements in a block, no inline keyword, no stdint.h and hence no 64bit types, etc), but it's not too bad once you get used to it. C++ is a bit less certain, as you're potentially relying on how complete the target compiler's support is for the standard. Remember the argument that if you want your web page to work on different browsers, then you should write standards-compliant HTML?Īt the language level, if your code compiles without warnings on GCC with -std=c89 (or -std=c++98 for C++), -pedantic -Wall, plus -Wextra if you're feeling brave, and as long as you haven't used any of the more blatant GNU extensions permitted by -pedantic (which are hard to do accidentally) then it has a good chance of working on most C89 compilers.
0 Comments
Leave a Reply. |