   Rules of Thumb when using C++ to develop multiplatform code
  I'm starting a project in C++, and I'm hoping to create linux and mac distributables for it once the project is finished. It's not really a priority, but if it's as simple as how I think it is, then it shouldn't be a problem.My assumption is that I'd have to use ISO standard C++ code, and libraries specifically written to be multi platform (Like SDL). Then I'd recompile the code using a specific os compiler et viola.Something tells me it's not that simple.   
Quote:Original post by WazzatManI'm starting a project in C++, and I'm hoping to create linux and mac distributables for it once the project is finished. It's not really a priority, but if it's as simple as how I think it is, then it shouldn't be a problem.My assumption is that I'd have to use ISO standard C++ code, and libraries specifically written to be multi platform (Like SDL). Then I'd recompile the code using a specific os compiler et viola.Something tells me it's not that simple.It should be, and if your coding practices are good, it will be.However, Microsoft headers/compilers have a particularly nasty habit of auto-including a bunch of platform-specific stuff, so make sure that you are actually writing std c++.Also be aware that if you want to run your program on older PowerPC based macs, you will need to take endianess into account when reading and writing files.   ;  Off the top of my head:- Be careful with byte-endian-ness.- Get your game building on at least one platform as soon as possible.- If you don't have hardware for other platforms available yet, then being able to build your project with multiple compilers (VS and GCC) will help.- You are going to have to write platform-specific code sooner or later, so figure out how you're going to keep that organised from the start, instead of having #ifdefs scattered everywhere.- Unit tests for platform-independant code can go a long way to ironing out platform-specific bugs in lower level libraries and code.Consider embedding a scripting language like Python or Lua for gameplay code which should work the same regardless of the underlying platform.   ;Quote:However, Microsoft headers/compilers have a particularly nasty habit of auto-including a bunch of platform-specific stuff, so make sure that you are actually writing std c++.I'm using minGW and codeblocks, so Microsoft headers shouldn't be a problem. Quote:If you don't have hardware for other platforms available yet, then being able to build your project with multiple compilers (VS and GCC) will help.I've downloaded virtualbox and I was thinking of using it for testing the game's compatibility with linux. That should give the same results as a linux machine, right?.Thanks for the help :).   ;Quote:Original post by WazzatManI've downloaded virtualbox and I was thinking of using it for testing the game's compatibility with linux. That should give the same results as a linux machine, right?.Yep, that's what I do. It works well :-)   ;Quote:Original post by WazzatManQuote:However, Microsoft headers/compilers have a particularly nasty habit of auto-including a bunch of platform-specific stuff, so make sure that you are actually writing std c++.I'm using minGW and codeblocks, so Microsoft headers shouldn't be a problem. Still worth compiling your code with VS once in a while - compiling with multiple, different compilers (both in strict mode) helps to catch a lot of non-standard code.   ;  Definately compile it now and then with gcc. It seems to be the strictest to the c++ standards and catches some things other compilers will let you get away with.Also get the different platforms up and running ( or find people here on gamedev to test for you - or use a VM ).. as there's bound to be quirks on each one that you'll need to address. Test on these platforms as you go, instead of just developing it all in windows and expecting it to work when your done.   