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

Makefile: set _POSIX_C_SOURCE #169

Merged
merged 1 commit into from
Jan 15, 2022
Merged

Makefile: set _POSIX_C_SOURCE #169

merged 1 commit into from
Jan 15, 2022

Conversation

ffontaine
Copy link

@ffontaine ffontaine commented Jan 12, 2022

Set -D_POSIX_C_SOURCE=200112L to avoid the following build failure with uclibc-ng:

anet.c: In function ‘anetTcpGenericConnect’:
anet.c:153:21: error: storage size of ‘gai_hints’ isn’t known
  153 |     struct addrinfo gai_hints;
      |                     ^~~~~~~~~

In file included from dump1090.h:83,
                 from dump1090.c:50:
compat/compat.h:46:3: error: conflicting types for ‘clockid_t’
   46 | } clockid_t;
      |   ^~~~~~~~~
In file included from /home/fabrice/buildroot/output/host/or1k-buildroot-linux-uclibc/sysroot/usr/include/sys/types.h:132,
                 from /home/fabrice/buildroot/output/host/or1k-buildroot-linux-uclibc/sysroot/usr/include/stdlib.h:198,
                 from dump1090.h:66,
                 from dump1090.c:50:
/home/fabrice/buildroot/output/host/or1k-buildroot-linux-uclibc/sysroot/usr/include/time.h:91:21: note: previous declaration of ‘clockid_t’ was here
   91 | typedef __clockid_t clockid_t;
      |                     ^~~~~~~~~

net_io.c: In function ‘writeJsonToFile’:
net_io.c:2122:18: error: ‘PATH_MAX’ undeclared (first use in this function)
 2122 |     char pathbuf[PATH_MAX];
      |                  ^~~~~~~~

Signed-off-by: Fabrice Fontaine [email protected]

@mutability mutability changed the base branch from master to dev January 14, 2022 03:42
@mutability
Copy link

The manpage I have here says:

           Since glibc 2.22: _POSIX_C_SOURCE >= 200112L
           Glibc 2.21 and earlier: _POSIX_C_SOURCE
CONFORMING TO
       POSIX.1-2001, POSIX.1-2008.  The getaddrinfo() function is documented in RFC 2553.

why does uclibc-ng need _GNU_SOURCE here, isn't struct addrinfo POSIX?

@mutability
Copy link

For clockid_t, do you know why the current test fails on uclibc-ng? (maybe CLOCK_REALTIME is not a macro there?). Should we maybe test for _POSIX_TIMERS instead (or as well as) testing for a CLOCK_REALTIME macro?

@mutability
Copy link

Missing PATH_MAX must mean something like your _DEFAULT_SOURCE doesn't turn on POSIX, that's really basic POSIX and we're including <limits.h>

@mutability
Copy link

I suspect that most of these problems are better solved by defining an appropriate _POSIX_C_SOURCE, rather than _GNU_SOURCE

Set -D_POSIX_C_SOURCE=200112L to avoid the following build failure with
uclibc-ng:

anet.c: In function ‘anetTcpGenericConnect’:
anet.c:153:21: error: storage size of ‘gai_hints’ isn’t known
  153 |     struct addrinfo gai_hints;
      |                     ^~~~~~~~~

In file included from dump1090.h:83,
                 from dump1090.c:50:
compat/compat.h:46:3: error: conflicting types for ‘clockid_t’
   46 | } clockid_t;
      |   ^~~~~~~~~
In file included from /home/fabrice/buildroot/output/host/or1k-buildroot-linux-uclibc/sysroot/usr/include/sys/types.h:132,
                 from /home/fabrice/buildroot/output/host/or1k-buildroot-linux-uclibc/sysroot/usr/include/stdlib.h:198,
                 from dump1090.h:66,
                 from dump1090.c:50:
/home/fabrice/buildroot/output/host/or1k-buildroot-linux-uclibc/sysroot/usr/include/time.h:91:21: note: previous declaration of ‘clockid_t’ was here
   91 | typedef __clockid_t clockid_t;
      |                     ^~~~~~~~~

net_io.c: In function ‘writeJsonToFile’:
net_io.c:2122:18: error: ‘PATH_MAX’ undeclared (first use in this function)
 2122 |     char pathbuf[PATH_MAX];
      |                  ^~~~~~~~

Signed-off-by: Fabrice Fontaine <[email protected]>
@ffontaine ffontaine changed the title Makefile: set -D_GNU_SOURCE Makefile: set _POSIX_C_SOURCE Jan 15, 2022
@ffontaine
Copy link
Author

Indeed, this is a better solution, I updated the PR

@mutability mutability merged commit 350664a into flightaware:dev Jan 15, 2022
@mutability
Copy link

Merged, thanks!

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

Successfully merging this pull request may close these issues.

None yet

2 participants