Next: , Previous: , Up: Invoking gnulib-tool   [Contents][Index]

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 ISO C and POSIX 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.

  1. Add the Gnulib module ‘posixcheck’ to the Gnulib imports of your package, as described earlier in this chapter.
  2. Do a make distclean if you previously built in the top-level directory. Then regenerate the Autotools-generated parts of the package.
  3. 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.
  4. Add the modules you noted to the Gnulib imports of your package.
  5. 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.
  6. Finally, remove the Gnulib module ‘posixcheck’ from the Gnulib imports, and run make distclean.

Next: Modifying the build rules of a Gnulib import directory, Previous: Changing your link commands for use with Gnulib, Up: Invoking gnulib-tool   [Contents][Index]