uNetworking / uWebSockets

Simple, secure & standards compliant web server for the most demanding of applications
Apache License 2.0
17.42k stars 1.76k forks source link

Failure to compile with ASIO #1601

Closed kylepl closed 1 year ago

kylepl commented 1 year ago

I synced to commit e5b1d3f83c0c2dcc7f8aaa1bbdd1bb5942e85081.

I think there is some bit where my system has to have access to boost (fine, expected), but even before that I am hitting compile errors with:

WITH_ASIO=1 make

Getting (note just make works):

cc -flto -DLIBUS_NO_SSL -DLIBUS_USE_ASIO -std=c11 -Isrc -O3 -c src/*.c src/eventing/*.c src/crypto/*.c
In file included from src/bsd.c:23:
src/internal/internal.h:119:5: error: unknown type name ‘uint32_t’
  119 |     uint32_t global_tick;                                                    
      |     ^~~~~~~~

Adding #include <stdint.h> to internal.h solves that, though it wasn't clear to me comparing epoll_kqueue header includes why that was needed. After that fix, I still get issues:

cc -flto -DLIBUS_NO_SSL -DLIBUS_USE_ASIO -std=c11 -Isrc -O3 -c src/*.c src/eventing/*.c src/crypto/*.c                                                                    
src/bsd.c:48:20: error: array type has incomplete element type ‘struct mmsghdr’      
   48 |     struct mmsghdr msgvec[LIBUS_UDP_MAX_NUM];                                                                                                                     
      |                    ^~~~~~        

which should be solved by #include <sys/socket.h>, but that is already included in bsd.c.

I may be missing something, so I figured I'd ask before investigating further. Thanks!

uNetworkingAB commented 1 year ago

The ASIO backend was made for a project that was later scrapped so it hasn't been updated recently. To fix it, you shouldn't need any low level headers like sys/socket and so on - it should be entirely isolated to high level ASIO headers other than integer file descriptors. With time, this ASIO backedn will be reqritten to C++20 native backend instead

kylepl commented 1 year ago

Thanks for the information.

It turned out that the fix of including #include <stdint.h>, was actually causing (for reasons I do not understand) several compile failure around missing def'ns of sys/socket.h, but only if included before internal/networking/bsd.h.

Do you want the one-line patch for #include <stdint.h>? With that, I have ASIO running.

uNetworkingAB commented 1 year ago

Where is #include needed?

kylepl commented 1 year ago

I've sent a PR (feel free to use that, or just notice where I am putting it): https://github.com/uNetworking/uSockets/pull/200.

uNetworkingAB commented 1 year ago

What platform is this on?

kylepl commented 1 year ago

I'm running on Linux, though I'm not sure if that is precise enough.