C Language Portability Goo

Good luck finding a consistent C standard that contains the functions you use. (Of course, C99 doesn't contain strdup. Why would it?). Don't even get me started on autoconf and its bretheren—talk about taking a bad problem and making it worse.

Here are two useful charts for tracking down the source of a particular C API:

And now, on to the specifics:

C Function Portability

clock_gettime

Platform | Has?	| #include	| Library	| #define
OpenBSD | y	| 	| 		|
Linux	| y	| 	| rt		|
MacOS X | n	|		|		|

Notes: Linux requires a -lrt. Also, Linux defines CLOCK_MONOTONIC, but it always returns a failure. Need to test for this and fall back to CLOCK_REALTIME.

pintday.org » Fresh every Tuesday.