3.7 Finding recommended ISO C and POSIX function substitutes
Gnulib contains a wealth of portability workarounds for ISO C and POSIX
functions. They are listed in detail in the chapter Function Substitutes.
If you want to know which function substitutes are recommended for your
package, you can search your source code for ISO C and POSIX functions
that it uses and read the corresponding sections of said documentation
chapter. But this is a tedious task. Here is an alternative approach
that makes this task easier.
- Add the Gnulib module ‘posixcheck’ to the Gnulib imports of your package,
as described earlier in this chapter.
- Do a
make distclean if you previously built in the top-level directory.
Then regenerate the Autotools-generated parts of the package.
- On a glibc system, build your package. Pay attention to the compiler warnings.
Warnings are generated for uses of ISO C and POSIX functions that have
portability problems or other important pitfalls and for which you have not yet
imported the corresponding Gnulib module. If you get, say, a warning
“warning: call to ’close’ declared with attribute warning: close does not
portably work on sockets - use gnulib module close for portability”,
put ‘close’ on your list of modules to import.
- Add the modules you noted to the Gnulib imports of your package.
- Optionally, you can do the same steps again, and make sure that there are no
warnings left except those that you want to intentionally ignore.
- Finally, remove the Gnulib module ‘posixcheck’ from the Gnulib imports,