X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:mime-version:from:date:message-id:subject:to
	:content-type:content-transfer-encoding; q=dns; s=default; b=Rfg
	EexCTwKu4Gflpn374BvbnHGMtgK8qIZQacxDA52YBxB/NvnO//UzzCaZC1CRatUg
	P037qodxI2PNqBU8KH9USPBf8vlLBGSAmR/OMQaWlgxDi+5ymIBfMCDyjTY0zR44
	OsUltOoer0ZfMCrivYl04UuaxAwtIcUpWUYyposk=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:mime-version:from:date:message-id:subject:to
	:content-type:content-transfer-encoding; s=default; bh=udtAY16x8
	Qp1gJJQY8Bqegb2/YE=; b=Jv+XRT/WwfTQagjR/D4FCQWz2Dq9SbMYydYtll5sU
	r6PpK0xahsLeTrefsfMSQW//0LTltkBpmh8Zy01WJ9vDBBzprMA03E3BTRzSiGD5
	Gkxbnq32+5VDP7/rid+gvTDDBGPRpFtc5i08gbCqwFoqRgiCAs4gu1Tqv5SJOpSN
	GE=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Searching, educated, H*c:alternative
X-HELO: mail-wr1-f46.google.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;        d=gmail.com; s=20161025;        h=mime-version:from:date:message-id:subject:to;        bh=OdtY36qcgsizPOAhz7jEQIdHiBsj2B5HoRsK5tIA1Ak=;        b=jKnhvddeDfXpPvsqRG/QHSl3hXBKq8y0TRwfSeeGmyV7GFnXfcDHo5WIqkBfR9B3m0         DiK8jjA72Emlk2qqmm7J84o0YYdUJm3iDswIJpoRGTRLWkkAs2CqN+QYvwhj0W09j+US         G6fifnDCY7L19+FNibNaeqeHXRMKKSdw+W3x2RqhH4rKzOtGLdzmYIhLZg889RdqscNa         qu/ryoqtW6XFbAqw7epaPv6IlOl7T2OiJ23ipKsGNpmAtdC+Z4s4cb/LbsylJ8kLy6T4         c/dytHRKghzZ4AF++xF/QIeokgY68Brp+I/ndjuK3m5OrzPNHM7faCBE6E8qaIxQrpWr         GzKw==
MIME-Version: 1.0
From: John Selbie <jselbie@gmail.com>
Date: Tue, 4 Sep 2018 22:55:54 -0700
Message-ID: <CAJn6YFD-zJoH4wtDaRq1EYYLwzWv_EYFWLGm+quj_RobFMv2Dg@mail.gmail.com>
Subject: Why does -std=c++11 hide certain function calls
To: cygwin@cygwin.com
Content-Type: text/plain; charset="UTF-8"
X-IsSubscribed: yes
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id w855uLWT018655

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


