3 ms·
Or you write platform specific code in it's own files, and link it in conditionally. port-linux.c port-win32.c port-solaris.c myprog.c and jus
by ori_b 15y ago
Or you write platform specific code in it's own files, and link it in conditionally.
port-linux.c
port-win32.c
port-solaris.c
myprog.c
and just compile/link port-$TARGET.c into your program. The code tends to be cleaner, and the platform knowledge is concentrated in one place.
- Arelius 15y agoIn my experience this is a much better approach. Most modern compilers can inline across linker boundaries anyways, so it's not a real performance issue either.
- LefterisJP 15y agoYes having platform specific code in its own header source and just #ifdef the includes provides much cleaner and nicer code
- ori_b 15y agoDon't even do that -- have one header that all the platform interfaces implement without ifdefs. Keep the conditional compilation in the makefiles, not in the source.