It's not like crossplatform code is hard to write. |
Actually, I think it is. You give up a lot of things if you always strive for cross-platform. It probably varies how long you will go the way..
You may not even realize what you give up if you do it all the time. I have a recent example for that. For a game, I wrote a particle engine based on templates. I wanted to have the users of the template (which are: "me" :) to implement certain functions in helper-structs which then get called in a callback-fashion. Except that I don't wanted to use virtual functions nor any kind of function pointer (performance reason. The update code itself was plain simple, but the virtual call made an overhead of about 10-15%).
So I used conditional calling teqniques. (Edit: well, that wasn't alone the reason, I could use plain inheritance too. But it was one of them. It's complicated. ;) ) A lot of heavy template stuff to determine whether a template argument has implemented a function or not.
Yesterday, someone in another forum pointed me to __if_exists() in MSVC and this is basically exactly what I wanted, except that there are no 150 lines of ugly template-code and 20-line error messages if something goes wrong. I am kind of scared at the moment what I could miss out by restricting my mind to "must be portable"... ;-)
That doesn't mean you should disregard the standard c++ and "write by trying". It means you should know your compiler, know your platform and all above know your requirements and then write the best thing you can do.
And don't get me wrong about the original spark that started this discussion: I am not advocating that people should put "\" in their header files under windows. I just think it's worth about a small side-note comment to the author of the guide like:
"Hey, yaknow.. even if your section is only about Windows and even if the MSVC-wizard generates files with \ in includes all the time, mixes up case of header files and so on.. and even if it might seem easier to copy'n'paste path things from windows without changing \ to /... you know that Windows works with / perfectly well and since you are writing an OpenGL guide and people might want to use OpenGL precisely because it's platform independend.. and people might jump from Google directly on your Guide without realizing your tips are windows-only and the Mac-section is just a couple of clicks away.. I think you should really strive to clean up your code from Windows-specifica where it isn't necessary. Regards."
Actually that's quite a lot of words for a side-note, but you get the idea of what "level of complain" I would expect for such a minor thing like "in which direction slashes are facing". Certainly not "Boah, look at that.. BACKSLASHES.. what an idiot. *Everyone* knows you get shot for using backslashes!"
Ciao, Imi.