public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* GCC-6.4 sys/select.h build failures with std=c++14
@ 2017-09-26  1:41 Ian Fette
  2017-09-26  4:49 ` Brian Inglis
  2017-09-26  5:33 ` Marco Atzeri
  0 siblings, 2 replies; 4+ messages in thread
From: Ian Fette @ 2017-09-26  1:41 UTC (permalink / raw)
  To: cygwin

I tried compiling a very simple program with curl using -std=c++14 under
64-bit cygwin with gcc 6.4.0. When compiling with just g++ main.cpp -lcurl
everything is fine, however if I try to use c++14 as the dialect (g++
main.cpp -lcurl -std=c++14) familiar problems creep up

In file included from /usr/include/curl/curl.h:2547:0,
                 from main.cpp:10:
/usr/include/curl/multi.h:155:40: error: ‘fd_set’ has not been declared
                                        fd_set *read_fd_set,
                                        ^~~~~~
/usr/include/curl/multi.h:156:40: error: ‘fd_set’ has not been declared
                                        fd_set *write_fd_set,
                                        ^~~~~~
/usr/include/curl/multi.h:157:40: error: ‘fd_set’ has not been declared
                                        fd_set *exc_fd_set,
                                        ^~~~~~


This is resolved by manually including <sys/select.h> before including
<curl/curl.h>

This was discussed in the curl project in the past (
https://github.com/curl/curl/issues/749) where it was determined that it
was caused by a cygwin bug which was addressed in
https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=newlib/libc/include/sys/types.h;h=c9f0fc7f3a9ca420c2372c9af42ce2a0e63e3b1c;hb=ee97c4b22491b205fd3b7697e03c909e02b652d3

If anyone has thoughts, I'd greatly appreciate it. Compiling the following
is sufficient to reproduce.

#include <iostream>
#include <curl/curl.h>

using namespace std;

int main() {

CURL *curl = curl_easy_init();
if(curl) {
  CURLcode res;
  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
  res = curl_easy_perform(curl);
  curl_easy_cleanup(curl);
}

}

--
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GCC-6.4 sys/select.h build failures with std=c++14
  2017-09-26  1:41 GCC-6.4 sys/select.h build failures with std=c++14 Ian Fette
@ 2017-09-26  4:49 ` Brian Inglis
  2017-09-26  5:33 ` Marco Atzeri
  1 sibling, 0 replies; 4+ messages in thread
From: Brian Inglis @ 2017-09-26  4:49 UTC (permalink / raw)
  To: cygwin

On 2017-09-25 19:41, Ian Fette wrote:
> I tried compiling a very simple program with curl using -std=c++14 under 
> 64-bit cygwin with gcc 6.4.0. When compiling with just g++ main.cpp -lcurl 
> everything is fine, however if I try to use c++14 as the dialect (g++ 
> main.cpp -lcurl -std=c++14) familiar problems creep up

> This is resolved by manually including <sys/select.h> before including 
> <curl/curl.h>

> This was discussed in the curl project in the past 
> (https://github.com/curl/curl/issues/749) where it was determined that it was
> caused by a cygwin bug which was addressed in 
> https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=newlib/libc/include/sys/types.h;
> h=c9f0fc7f3a9ca420c2372c9af42ce2a0e63e3b1c;hb=ee97c4b22491b205fd3b7697e03c909e02b652d3
> If anyone has thoughts, I'd greatly appreciate it.

A lot of GNU and Cygwin package build problems are avoided by building either
without any -std=... option, or equivalently with -std=gnu++nn, which enables
many non-portable GCC extensions and Unix features, instead of -std=c++nn, which
disables GCC extensions and Unix features, and accepts only portable features
supported by GCC and C++ headers you specify.

In general, try replacing -std=c... with -std=gnu... or omitting -std=... and
see if your program builds without errors or warnings.
Adding -Wall -Wextra will let you know if anything appears questionable to the
compiler.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

--
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GCC-6.4 sys/select.h build failures with std=c++14
  2017-09-26  1:41 GCC-6.4 sys/select.h build failures with std=c++14 Ian Fette
  2017-09-26  4:49 ` Brian Inglis
@ 2017-09-26  5:33 ` Marco Atzeri
  2017-09-26 19:33   ` Hans-Bernhard Bröker
  1 sibling, 1 reply; 4+ messages in thread
From: Marco Atzeri @ 2017-09-26  5:33 UTC (permalink / raw)
  To: cygwin



On 26/09/2017 03:41, Ian Fette wrote:
> I tried compiling a very simple program with curl using -std=c++14 under
> 64-bit cygwin with gcc 6.4.0. When compiling with just g++ main.cpp -lcurl
> everything is fine, however if I try to use c++14 as the dialect (g++
> main.cpp -lcurl -std=c++14) familiar problems creep up
> 
> In file included from /usr/include/curl/curl.h:2547:0,
>                   from main.cpp:10:
> /usr/include/curl/multi.h:155:40: error: ‘fd_set’ has not been declared
>                                          fd_set *read_fd_set,
>                                          ^~~~~~
> /usr/include/curl/multi.h:156:40: error: ‘fd_set’ has not been declared
>                                          fd_set *write_fd_set,
>                                          ^~~~~~
> /usr/include/curl/multi.h:157:40: error: ‘fd_set’ has not been declared
>                                          fd_set *exc_fd_set,
>                                          ^~~~~~
> 
> 
> This is resolved by manually including <sys/select.h> before including
> <curl/curl.h>
> 

this seems more an issue of curl header as from
http://pubs.opengroup.org/onlinepubs/009696899/basedefs/sys/select.h.html

"The <sys/select.h> header shall define the fd_set type as a structure."

so if they are using it, they should have a proper include

Marco


--
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GCC-6.4 sys/select.h build failures with std=c++14
  2017-09-26  5:33 ` Marco Atzeri
@ 2017-09-26 19:33   ` Hans-Bernhard Bröker
  0 siblings, 0 replies; 4+ messages in thread
From: Hans-Bernhard Bröker @ 2017-09-26 19:33 UTC (permalink / raw)
  To: cygwin

Am 26.09.2017 um 07:32 schrieb Marco Atzeri:

> "The <sys/select.h> header shall define the fd_set type as a structure."
> 
> so if they are using it, they should have a proper include

The complete story is a bit more complicated than that, though.

The curl maintainers almost fixed this at their end, but then Cygwin 
reverted part of a change that had "suddenly" triggered their broken 
code to actually fail before they did.  Before then, Cygwin's fd_set was 
actually in <sys/types.h>, which was then #included by <sys/select.h>. 
The change was to define them it <sys/select.h> where it belongs

But then the second change was made (commit 
ee97c4b22491b205fd3b7697e03c909e02b652d3), which reintroduced

# if    __BSD_VISIBLE
#include <sys/select.h>

in <sys/types.h>.  This actually re-introduced a part of the original 
POSIX violation in Cygwin: #including <sys/types.h> will, again, drag in 
<sys/select.h> even though that was not asked for.  Apparently this 
violation is sufficiently wide-spread that there's quite some code out 
there that relies on it.  Curl is in this group.
		
All this seems to have left the Curl people under the impression that 
there was nothing wrong with their code, but that rather Cygwin was 
broken, and for a relatively short time only, too (2015-12-17 to 
2016-03-18).  The fragment in question is positively hideous:

#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \
   defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \
   defined(ANDROID) || defined(__ANDROID__) || defined(__OpenBSD__) || \
  (defined(__FreeBSD_version) && (__FreeBSD_version < 800000))
  #include <sys/select.h>
  #endif

Now people complain about autoconf being clunky, but it's easily an 
order of magnitude better than _that_ pile of nonsense --- particularly 
given the fact that they actually use autoconf to build their code. 
They just don't do so in their public, installable header file.

--
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-09-26 19:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-26  1:41 GCC-6.4 sys/select.h build failures with std=c++14 Ian Fette
2017-09-26  4:49 ` Brian Inglis
2017-09-26  5:33 ` Marco Atzeri
2017-09-26 19:33   ` Hans-Bernhard Bröker

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).