How do multiplatform things work?

I was wondering when people code things that work in all 3 platforms do they code 3 separate things or do they not do certain things in the code. Or does this depend on the compiler?

Write once well. You can use libraries with multi platform support and avoid code that's platform dependant

Some languages like Java were designed to be written once and compiled when run so that it works on just about anything. That is one reason why it is so horrible.

Ya that worked out well for them. Imagine every program ending in .jar lol

It depends. Usually it's not doing something platform specific in code, so you could compile on any platform, because usually what you need is just some functionality that comes easy on any platform with no changes. Then come the times when you need to interface with a feature that varies from os to os, then you have the option to implement the code for every platform yourself, or you can use a library that does that for you (the better choice). For an example trying to write a GUI for windows on C++ with the windows api, not only the api sucks but you can't run it anywhere else. But if you use QT you have a whole array of cool features that runs on any platform (QT is very cool, recommended if you wanna write a GUI with C++). There are times when simple solutions just don't cut it though. Sometimes the libraries available provide overhead you just can't accept or smth, or that library sucks for something you wanna do. It's all about what you wanna do and what tools do you have.