Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add -D_POSIX_C_SOURCE=200809L #170

Merged
merged 1 commit into from
Aug 6, 2016
Merged

build: add -D_POSIX_C_SOURCE=200809L #170

merged 1 commit into from
Aug 6, 2016

Conversation

gperciva
Copy link
Member

@gperciva gperciva commented Jul 3, 2016

Without this, clang-3.8 with -std=c99 on Ubuntu 16.04 fails to find SSIZE_MAX
in limits.h. This is because SSIZE_MAX is in .../bits/posix1_lim.h, and
/usr/include/limits.h contains:

#ifdef  __USE_POSIX
/* POSIX adds things to <limits.h>.  */
# include <bits/posix1_lim.h>
#endif

and in "STRICT_ANSI" mode (implied by -std=c99, amongst other things),
__USE_POSIX is only defined if we've defined _POSIX_C_SOURCE or _XOPEN_SOURCE.

Without this, clang-3.8 with -std=c99 on Ubuntu 16.04 fails to find SSIZE_MAX
in limits.h.  This is because SSIZE_MAX is in .../bits/posix1_lim.h, and
/usr/include/limits.h contains:

    #ifdef  __USE_POSIX
    /* POSIX adds things to <limits.h>.  */
    # include <bits/posix1_lim.h>
    #endif

and in "__STRICT_ANSI__" mode (implied by -std=c99, amongst other things),
__USE_POSIX is only defined if we've defined _POSIX_C_SOURCE or _XOPEN_SOURCE.
@gperciva
Copy link
Member Author

gperciva commented Jul 3, 2016

This is copied from Tarsnap/scrypt#55

@cperciva
Copy link
Member

cperciva commented Aug 6, 2016

I'm slightly worried that this may break other platforms, by convincing them to hide non-POSIX functions... I'm going to merge it for now, but be aware that there may be fallout later.

@cperciva cperciva merged commit 53d8b61 into master Aug 6, 2016
@gperciva
Copy link
Member Author

gperciva commented Aug 6, 2016

Hmm? SSIZE_MAX is notated as being [CX]:

[CX] Some of the functionality described on this reference page extends the ISO C standard. Applications shall define the appropriate feature test macro (see XSH The Compilation Environment ) to enable the visibility of these symbols in this header.
...
[CX]  Extension to the ISO C standard 
The functionality described is an extension to the ISO C standard. Application developers may make use of an extension as it is supported on all POSIX.1-2008-conforming systems.
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html

So it makes sense to me that we need to use -D_POSIX_C_SOURCE=200809L. We use it in cperciva software... I feel like I'm missing something here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants