Defining feature test macros
We have already seen several examples of when we have included either a POSIX standard or some specific C standard. For example, when we used
getopt(), we defined
_XOPEN_SOURCE 500 at the very top of the source code file (
mph-to-kph_v2.c from Chapter 2, Making Your Programs Easy to Script).
A feature test macro controls the definitions that are exposed by system header files. We can leverage this in two ways. Either we can use it to create portable applications by using a feature test macro that prevents us from using non-standard definitions or we can use it the other way around, allowing us to use non-standard definitions.
We will write two small programs in this recipe,
which-c.c. You can either download them from https://github.com/PacktPublishing/Linux-System-Programming...