Question: A book I am reading suggests compiling programs on the machines they are intended for to ensure there isn't any issues. One of the big reasons I wanted to learn C is because it (can be) compatible with all operating systems. I am using this one on linux. If compiling the program on the intended machine(s) is not an option, is there a procedure that can be followed to ensure the program will run perfectly regardless of what version of linux/bsd it is run on? Like a crib sheet of compatible functions for different O/S as well as different architectures, and how to deal with each difference to ensure compatability?

Answer: 
Use libraries intended to work cross platform. If you do need to do anything that is platform dependent, you will have to write code that accounts for all architectures/platforms you want your application to run on.

Specific platforms will have `#define X` to determine if that's what the code runs on, so you can `#ifdef X` to check a specific platform and then write your code inside that statement, do the same for each bit of platform specific code.
I would consult the following couple of links to get some basic information

<http://en.wikipedia.org/wiki/Linux_Standard_Base>

<http://www.linuxfoundation.org/collaborate/workgroups/lsb>