-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate sockaddr structs. #19972
Comments
how did u call zig on the command line? what arch/os is your host? |
@nektro |
const std = @import("std");
const net = std.net;
const posix = std.posix;
const print = std.debug.print;
pub fn main() !void {
const ip: []const u8 = "127.0.0.1";
const port: u16 = 3000;
const addr = try net.Address.parseIp4(ip, port);
const sock = try posix.socket(posix.AF.INET, posix.SOCK.DGRAM, 0);
try posix.bind(sock, &addr.any, addr.getOsSockLen());
}
its the exact opposite, std.posix is an abstraction over different systems that implement posix so |
@xdBronch Thank for the clarification! There is one thing Im still unsure about though. I ended up in using std.net because I wanted to parse an address into a sockaddr struct. Is there a way to do this for the std.os.linux? or is it supposed to be used in a different way? I will just use the posix lib for simplicity, but what I intend on making will end on a linux server. |
If you write a program for Linux and want to compile it on MacOS you need to specify |
Zig Version
0.12.0
Steps to Reproduce and Observed Behavior
Hello! I have been having some issues the os.linux.socket to work.
Problem:
The sockaddr struct is declared in std.os and std.posix. This causes a type conflict when binding to a port because the compiler thinks they are different structs.
(main.zig:14:30: error: expected type 'os.linux.sockaddr', found 'c.darwin.sockaddr')
I was uncertain if this was a skill issue so I did a diff to make sure that they are the same struct.
Here is the code that produces the issue:
Expected Behavior
I would expect to not get this issue since they are exactly the same. I would imagine std.os should reference the std.posix?
The text was updated successfully, but these errors were encountered: