From: John Selbie <jselbie@gmail.com>
To: cygwin@cygwin.com
Subject: Why does -std=c++11 hide certain function calls
Date: Wed, 05 Sep 2018 05:56:00 -0000 [thread overview]
Message-ID: <CAJn6YFD-zJoH4wtDaRq1EYYLwzWv_EYFWLGm+quj_RobFMv2Dg@mail.gmail.com> (raw)
Updating Stuntman (Open source Stun Server) from C++ to modern C++. I ran
into an issue.
This code:
#include <stdio.h>
#include <sys/socket.h>
#include <netdb.h>
int some_networking_code()
{
addrinfo* addr = NULL;
int flags = AI_NUMERICHOST;
return 0;
}
Compiles fine everywhere: with: g++ foo.cpp -c
With this: g++ foo.cpp -c -std=c++11
It compiles fine everywhere else, except CygWin. Output on Cygwin:
foo.cpp: In function ‘int some_networking_code()’:
foo.cpp:8:4: error: ‘addrinfo’ was not declared in this scope
foo.cpp:9:16: error: ‘AI_NUMERICHOST’ was not declared in this scope
Digging in further, I see that /usr/include/netdb.h has macros for blocking
declarataion of these items:
#if __POSIX_VISIBLE >= 200112 && !defined(__INSIDE_CYGWIN_NET__)
struct addrinfo {
int ai_flags; /* input flags */
… <deleted for brevity>
#endif
And when the macros are inspected with: g++ foo.cpp -c -std=c++11 -dM -E |
grep POSIX_VIS
We can see that:
#define __POSIX_VISIBLE 0
Which explains the compiler output.
Searching the mailing list archives, I see I'm not the first to observe
something this:
http://sourceware.org/ml/cygwin/2017-01/msg00392.html
Yes, switching to -std=gnu++11 or adding -D_DEFAULT_SOURCE to the command
line line works.
But I don't understand why the need to enforce these extensions to get
access to some of the most common unix libraries? When the goal of Cygwin
is to allow Unix code to be rebuilt for Windows easily, it feels dirty that
my Makefile will need Cygwin specific adjustments. Why not just take out
the __POSIX_VISIBLE>=200112 check altogether? If I'm missing the point of
something obvious, I'd be open to be educated on this.
Thanks,
jselbie
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
next reply other threads:[~2018-09-05 5:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-05 5:56 John Selbie [this message]
2018-09-05 18:46 ` Hans-Bernhard Bröker
2018-09-05 19:36 ` John Selbie
2018-09-05 20:41 ` Brian Inglis
2018-09-06 0:14 ` Doug Henderson
2018-09-06 6:45 ` John Selbie
2018-09-06 9:18 ` Csaba Raduly
2018-09-06 14:07 ` Jeffrey Walton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAJn6YFD-zJoH4wtDaRq1EYYLwzWv_EYFWLGm+quj_RobFMv2Dg@mail.gmail.com \
--to=jselbie@gmail.com \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).