[CDRIVER-2554] either the whole cdriver, or at least its public headers should compile with -std=c11 Created: 16/Mar/18  Updated: 08/Jan/24  Resolved: 29/Mar/18

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Gabriel Russell (Inactive) Assignee: A. Jesse Jiryu Davis
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

On my machine, at least, compiling the server against the cdriver doesn't work right because the cdriver headers expose struct addrinfo. The server compiles c code with -std=c11 and c11 excludes the definition of struct addrinfo, at least on my platform.



 Comments   
Comment by A. Jesse Jiryu Davis [ 29/Mar/18 ]

I think this works as designed, LMK if you want to continue the discussion.

Comment by A. Jesse Jiryu Davis [ 23/Mar/18 ]

I'm not sure it's a workaround for a bug. Including "_XOPEN_SOURCE=600" might just be the way you have to compile your code if you include the C Driver's header files. We do refer to POSIX socket APIs in our public function signatures, and those APIs aren't in C99. mira.carey@mongodb.com what do you think, is this a bug? If so, how do we fix it? Something vaguely like?:

#if __STDC_VERSION__ >= 199901L
MONGOC_EXPORT (int)
mongoc_socket_connect (mongoc_socket_t *sock,
                       void *addr,
                       size_t addrlen,
                       int64_t expire_at);
#else
MONGOC_EXPORT (int)
mongoc_socket_connect (mongoc_socket_t *sock,
                       const struct sockaddr *addr,
                       mongoc_socklen_t addrlen,
                       int64_t expire_at);
#endif

Comment by Gabriel Russell (Inactive) [ 22/Mar/18 ]

It's not urgent. I'm content working around this, in a way like you offer, for the time being.

Comment by A. Jesse Jiryu Davis [ 22/Mar/18 ]

Gabe what's the urgency of this please?

You may just need to include "-D_XOPEN_SOURCE=600" in your CFLAGS, to include the 2004 Posix stuff along with C99 standard: http://pubs.opengroup.org/onlinepubs/009695399/

Generated at Wed Feb 07 21:15:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.