cposix

C Code is too heavily compiler dependent


I'm writing an OS that should run on a variety of SoCs (e.g: Xilinx Zync, Freescale QorIQ). My problem, not all of the provided IDEs (given by Xilinx, Freescale, etc.) provide the same libraries (standard C & POSIX libraries). For instance, the CodeWarrior IDE has the timespec structure, while Xilinx's doesn't. Also, sleep is implemented in some of the provided libs, but I have my own implementation.

I want my code to be independent of the compiler (some manufacturers provide more than one IDE and with a different compiler).

Any suggestions?


Solution

  • My suggestion: Code to POSIX standards. Where the vendor library falls short of POSIX, implement a POSIX layer yourself.

    Leave the core OS generally #ifdef-free, and put the mess in a conditionally-compiled compatibility layer.