DRW wrote:
rainwarrior wrote:
All that said, though, it's perfectly reasonable to learn what to avoid and develop cross platform code. I'm just saying that there are a lot of things you must do to achieve this that have nothing to do with "improving" the code, and more to do with appeasing the arbitrary whims of the compiler gods.
I'd like to see a concrete example where you write a piece of code that is standard compliant, but where Visual Studio refuses to compile.
Luckily for you, Microsoft keeps a list:
http://msdn.microsoft.com/en-us/library/x84h5b78%28v=vs.110%29.aspxThe things that cause me more grief are the extensions they've added to the language.
For example, there are a number of miscellaneous string manipulation functions which have existing standards (albeit extra-C++/C89) that Microsoft arbitrarily chooses to ignore, instead implementing their own slightly differently named or slightly differently behaving version. Not to mention that MSVC puts a deprecation warning on quite a few standard C library functions that creates unnecessary warning spam (or the hassle of manually disabling them in every project), or even worse if your team compiles with warnings as errors and has a policy against disabling those warnings, now requiring a separate implemention to use MSVC's "secure" alternatives to these deprecated functions. There's a little bit of info on this here:
http://en.wikipedia.org/wiki/String.h#Popular_extensionsMicrosoft chose to implement a small subset of C99 features, neglecting others. It's a tease, really, especially since some of those features can produce better/more readable code (e.g. named member initialization of structs), or things like inttypes.h the lack of which requires every cross platform project I've worked on to have a global compiler-specific set of typedefs for MSVC and one for more C99 compliant compilers.
There are other things, but these are the ones I remember dealing with the most.
Sure, your answer to this can be "write code only to the C++ standard, and don't use any of their extensions, and don't use anything from those noncompliant fringes, and deal with their deprecation warnings", but as I said, none of this has anything to do with writing better code. At this point you're just dancing for the compiler makers. The other thing is, really learning the boundaries of the minimal standard takes years of experience working with a lot of different compilers, especially since every compiler comes with a ton of extensions on by default; this is actually a
very difficult constraint for a novice programmer to live by.
As I said, though, every compiler has similar problems. Microsoft is just particularly fond of going their own way when it comes to extensions instead of adopting other existing standardized extensions that are functionally equivalent, which is rather irksome. They've deliberately created a compiler that doesn't really play well with others outside the rigid lines of the bare standards.