uNetworking / uSockets

Miniscule cross-platform eventing, networking & crypto for async applications
Apache License 2.0
1.29k stars 268 forks source link

Errors upon building on Windows #88

Closed dmitigr closed 4 years ago

dmitigr commented 4 years ago

Hello,

The following declaration leads to build errors since the "interface" is a defined macro on Windows:

WIN32_EXPORT struct us_socket_t us_socket_context_connect(int ssl, struct us_socket_context_t context, const char host, int port, const char interface, int options, int socket_ext_size);

Thanks!

dmitigr commented 4 years ago

Btw, I can provide a patch with renamings "interface" to "intrface".

ghost commented 4 years ago

I build daily on Windows via CI without problems. Where is interface a macro? Why would anyone define a lowercase macro? There is no keyword called interface in C nor C++.

dmitigr commented 4 years ago

On Windows 10 "interface" is a macro defined in combaseapi.h like that:

#if defined(__cplusplus) && !defined(CINTERFACE)
...
#define __STRUCT__ struct
#define interface __STRUCT__
...
#else
...
#define interface               struct
...
#endif

combaseapi.h is included by objbase.h included by Ole2.h included by Windows.h included by Winsock2.h. Inclusion of Ole2.h could be prevented by defining WIN32_LEAN_AND_MEAN before including Windows.h but I would just rename "interface" to something else.

ghost commented 4 years ago

What the fuck is wrong with Microsoft

ghost commented 4 years ago

I don't like intrface as a broken word.

ghost commented 4 years ago

Source_host? As a variant of host

dmitigr commented 4 years ago

Since the bind(2) manual says: "traditionally, this operation is called “assigning a name to a socket”", how about "socket_name"?

dmitigr commented 4 years ago

Another alternative is "socket_host".

connorjak commented 4 years ago

I fixed some issues today by putting my #include libusockets.h above other #includes. Maybe that can help?

wxyu247 commented 4 years ago

interface -> hostName?

dmitigr commented 4 years ago

So, what about "interface" -> "socket_name" or "socket_host" or "source_host"? @alexhultman, please decide, and I'll be happy to provide a patch. Thanks.

dmitigr commented 4 years ago

Thanks for the fix.