This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Problems with evolving feature test macros?


Hello all,

One of the things man-pages tries to do is document the feature test
macro requirements for each API. Furthermore, since programmers may
have to target multiple glibc versions, the pages attempt to document
the evolution of each interface's feature test macro requirements
across glibc versions.

Given https://sourceware.org/ml/libc-alpha/2013-04/msg00355.html, I
decided to look at qecvt(3) as an example of what's happening over
time.

Over glibc versions, it looks as though you can get qecvt() exposed
from <stdlib.h> by defining FTMs as follows

    Before glibc 2.10:
        _SVID_SOURCE || _XOPEN_SOURCE >= 500 ||
            (_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED)

    glibc 2.10 to glibc 2.17
        _SVID_SOURCE || (_XOPEN_SOURCE >= 500 ||
            (_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) &&
                ! (_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700))

   glibc 2.18 to glibc 2.19
        _BSD_SOURCE || _SVID_SOURCE

   glibc 2.20 onward
        _DEFAULT_SOURCE

Now, I may not be 100% correct on the details (and I'm not at all sure
that there are only 4 different cases), but the broad brush picture is
probably close.

I've taken qecvt(3) as an example because it was discussed in the mail
thread, and probably it is one of the more striking cases, but I
imagine that there are a number of similar cases out there.

My point is that this sort of progression looks disastrous for
programmers who are trying to code for multiple glibc versions. In the
face of the above complexity, I'm guessing programmers will reach for
the only hammer that does not cause a compiler warning on any glibc
version:

#define _GNU_SOURCE

That seems to be a very unfortunate situation.

Have I missed something? How are glibc consumers supposed to deal with this?

Cheers,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]