natalie icon indicating copy to clipboard operation
natalie copied to clipboard

Socket errors on macOS

Open timcraft opened this issue 2 years ago • 0 comments

Attempting to load the socket library on macOS fails with a number of undeclared identifier errors:

$ bin/natalie -e "require 'socket'"
/var/folders/wc/ng7w8yms69j6vpvqck4x2shh0000gn/T/natalie.cpp20221003-18022-x9mqwj:1181:81: error: use of undeclared identifier 'AF_AX25'
    auto const_set75 =  self->const_set(symbols[19]/*:AF_AX25*/, Value::integer(AF_AX25));
/var/folders/wc/ng7w8yms69j6vpvqck4x2shh0000gn/T/natalie.cpp20221003-18022-x9mqwj:1188:83: error: use of undeclared identifier 'AF_PACKET'
    auto const_set82 =  self->const_set(symbols[26]/*:AF_PACKET*/, Value::integer(AF_PACKET));
...
...
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

Reading around I think we might need to #define __APPLE_USE_RFC_3542 before including including <netinet/in.h>[^1] but I can't find the correct place to put that where it'll fix the errors.

Where should that line go where it will be picked up by require 'socket.cpp' correctly?

[^1]: See comment in https://opensource.apple.com/source/xnu/xnu-1699.32.7/bsd/netinet6/in6.h

timcraft avatar Oct 03 '22 10:10 timcraft