[Poppler-bugs] [Bug 27610] snprintf() is undefined by _XOPEN_SOURCE=500 on BSDs, making poppler 0.12.4 fail to compile.

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Tue Apr 13 15:32:38 PDT 2010


https://bugs.freedesktop.org/show_bug.cgi?id=27610

--- Comment #2 from Javier Villavicencio <the_paya at gentoo.org> 2010-04-13 15:32:38 PDT ---
(In reply to comment #1)
> Can you point to the spec that says that snprintf shall be undefined when
> -D_XOPEN_SOURCE=500
> 
> I added the strings.h include for strcasecmp

Thanks.
About the specs, my apologies I should have included the references while I had
them at hand, and "correctly undefined" sounds a bit blunt. Silly of me.

To correct myself on the subject, what I found while investigating this is
that, since snprintf behavior was redefined between standards [1], the headers
only define it (and a few others) when the standard the library supports is in
use or requested, which is (usually) SUSv2 or ISO C99 or POSIX98 (not 100% sure
on the posix one).

While _XOPEN_SOURCE=500 goes back to pre-1998 (speaking of standards) and that
(older) implementation of snprintf is not supported on BSD (neither on glibc I
think), it's then left undefined (a suggestive way for programs to provide the
implementation they want, if I may add).
Linux glibc also behaves in a similar way: one of the requisites for defining
snprintf in <stdio.h> is "_XOPEN_SOURCE > 500" (coming from <features.h>). But
it's then ||or'ed to another define that comes from _BSD_SOURCE (it sets
__USE_BSD), which is a bliss for glibc in this case, given that -D_BSD_SOURCE
is also defined by poppler here.

[1] http://www.opengroup.org/onlinepubs/009695399/functions/snprintf.html (at
the bottom)

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the Poppler-bugs mailing list