standards: System Functions

1 
1 5.7 Calling System Functions
1 ============================
1 
1 Historically, C implementations differed substantially, and many systems
1 lacked a full implementation of ANSI/ISO C89.  Nowadays, however, all
1 practical systems have a C89 compiler and GNU C supports almost all of
1 C99 and some of C11.  Similarly, most systems implement POSIX.1-2001
1 libraries and tools, and many have POSIX.1-2008.
1 
1    Hence, there is little reason to support old C or non-POSIX systems,
1 and you may want to take advantage of standard C and POSIX to write
1 clearer, more portable, or faster code.  You should use standard
1 interfaces where possible; but if GNU extensions make your program more
1 maintainable, powerful, or otherwise better, don't hesitate to use them.
1 In any case, don't make your own declaration of system functions; that's
1 a recipe for conflict.
1 
1    Despite the standards, nearly every library function has some sort of
1 portability issue on some system or another.  Here are some examples:
1 
1 'open'
1      Names with trailing '/''s are mishandled on many platforms.
1 
1 'printf'
1      'long double' may be unimplemented; floating values Infinity and
1      NaN are often mishandled; output for large precisions may be
1      incorrect.
1 
1 'readlink'
1      May return 'int' instead of 'ssize_t'.
1 
1 'scanf'
1      On Windows, 'errno' is not set on failure.
1 
1    Gnulib (http://www.gnu.org/software/gnulib/) is a big help in this
1 regard.  Gnulib provides implementations of standard interfaces on many
1 of the systems that lack them, including portable implementations of
1 enhanced GNU interfaces, thereby making their use portable, and of
1 POSIX-1.2008 interfaces, some of which are missing even on up-to-date
1 GNU systems.
1 
1    Gnulib also provides many useful non-standard interfaces; for
1 example, C implementations of standard data structures (hash tables,
1 binary trees), error-checking type-safe wrappers for memory allocation
1 functions ('xmalloc', 'xrealloc'), and output of error messages.
1 
1    Gnulib integrates with GNU Autoconf and Automake to remove much of
1 the burden of writing portable code from the programmer: Gnulib makes
1 your configure script automatically determine what features are missing
1 and use the Gnulib code to supply the missing pieces.
1 
1    The Gnulib and Autoconf manuals have extensive sections on
DONTPRINTYET 1 portability: ⇒Introduction (gnulib)Top. and *note1DONTPRINTYET 1 portability: ⇒Introduction (gnulib)Top. and ⇒
 (autoconf)Portable C and C++.  Please consult them for many more
1 details.
1