Closed dbohdan closed 1 year ago
That's a bug in the C importer; "sys/socket.h" should definitely work. Lemme look into it.
Okay, AF_INET added. sin_family won't work, because sockaddr_in won't work; the definition is "a bit complicated". Manually declare struct sockaddr_in
for now.
module socket_test;
macro import std.macro.cimport;
import c_header("netinet/in.h");
import c_header("sys/socket.h");
void main(string[] args) {
mut sockaddr_in serv;
serv.sin_family = AF_INET;
}
struct sockaddr_in
{
sa_family_t sin_family;
in_port_t sin_port;
in_addr sin_addr;
// that's what it is on my system
Vector(ubyte, 8) sin_zero;
}
Closing as WONTFIX, but reopen if this is something that you need strongly/feel strongly about.
I am trying to translate the following C code to Neat:
I can't access
AF_INET
withimport c_header("sys/socket.h");
. I guess this is because on Linux with glibc it is defined inbits/socket.h
instead, whichsys/socket.h
includes. This a problem in Neat, sincebits/socket.h
prevents you from importing it directly.import c_header("bits/socket.h");
results in a GCC error during compilation.The compiler then acts like it's compiled the import but still can't use the constant.
Test file:
Error:
Additionally, if I remove
AF_INET
, I get the following error, probably for similar reasons?Test file:
Error: