Skip to content

<sys/select.h> missing include on cygwin #1925

@ifette

Description

@ifette

I realize this was discussed in the past in #749 however the issue has re-surfaced and I'm hoping people will re-consider.

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

I brought this up on the cygwin mailing list, and the response there (which, for what it's worth I happen to agree with) is that if curl is using fd_set it should be explicitly including <sys/select.h>.

If you look at the spec (http://pubs.opengroup.org/onlinepubs/009696899/basedefs/sys/select.h.html) it is indeed sys/select.h that defines the fd_set type. The docs for sys/types.h (http://pubs.opengroup.org/onlinepubs/009696899/basedefs/sys/types.h.html) make no guarantee about fd_set being included.

Given that this is a one line change that should have zero adverse impact on other platforms, is it possible to have curl explicitly include sys/select.h? (I haven't done any exhaustive testing to see if other platforms are impacted by the current state of the world when trying to compile with -std=c++14).

Simple repro:

#include
#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);
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions