The "plan9 way" to solve the problem of supporting different OSs in your program is to factor out the os specific parts and put them in a single file (eg macos.c linux.c, plan9.c etc) and a matching set of makefiles (make.macos, make.unix, (plan9 would have a mkfile of course)).
The best example of this I know is portable version of the sam the editor /sys/src/cmd/unix/sam - sadly the plan9 version has diverged from this over the years but the principal is still valid. -Steve
