zig icon indicating copy to clipboard operation
zig copied to clipboard

POSIX link() syscall only takes two arguments (no flags)

Open rootbeer opened this issue 1 year ago • 1 comments

The signature is documented as:

   int link(const char *, const char *);

(see https://man7.org/linux/man-pages/man2/link.2.html or https://man.netbsd.org/link.2)

And its not some Linux extension, the syscall implementation only expects two arguments too.

It probably should have a flags parameter, but its too late now.

I am a bit surprised that linking glibc or musl against Zig code that invokes a 'link' with three parameters doesn't fail (at least, I couldn't get any local test cases to trigger a compile or link error). But the extra argument should be harmless anyway.

The test case in std/posix/test.zig is currently disabled, but if I manually enable it, it works with this change.

rootbeer avatar Aug 01 '24 06:08 rootbeer

I guess this was just copy/paste error?

I am a bit surprised that linking glibc or musl against Zig code that invokes a 'link' with three parameters doesn't fail (at least, I couldn't get any local test cases to trigger a compile or link error). But the extra argument should be harmless anyway.

C doesn't do name mangling in the C++ sense so it will happily link with mismatched parameters/arguments.

alexrp avatar Aug 01 '24 06:08 alexrp

Thanks!

andrewrk avatar Aug 07 '24 20:08 andrewrk