Commit 3fc006d
committed
Fix missing declarations of "POSIX"
When (cross?) compiling this crate to Windows (in a Rust project) using
Clang 16 or newer, we're seeing these declaration errors:
> cargo b --target x86_64-pc-windows-msvc
warning: [email protected]: /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/metis-sys-0.3.1/vendor/GKlib/io.c(63,18): error: call to undeclared function 'read'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
warning: [email protected]: 63 | if ((rsize = read(fd, buf, tsize)) == -1)
warning: [email protected]: | ^
...
warning: [email protected]: /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/metis-sys-0.3.1/vendor/GKlib/io.c(84,17): error: call to undeclared function 'write'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
warning: [email protected]: 84 | if ((size = write(fd, buf, tsize)) == -1)
warning: [email protected]: | ^
(LIHPC-Computational-Geometry/metis-rs#43 (comment))
Now it's yet unknown (we haven't checked) if older Clang had these
declarations in a header, or didn't treat this warning as error yet,
but the functions are POSIX which Windows isn't required to implement.
Fortunately they provide it but with a deprecation warning and a
recommended replacement of `_read()` (and `_write()`), but for this
`<io.h>` needs to be included:
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/posix-read
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/read
The same is true for `getpid()` that commit a8e7e25 ("port to vs2017")
used to provide a `win32/adapt.c/h` workaround for, but this can instead
be pulled from `<process.h>` (equally with a deprecation warning, but
we should probably address these all in a consistent manner instead
of defining a workaround). Let's take this as a starting point and go
from there.read()/write() on Windows with Clang1 parent 6760c62 commit 3fc006d
4 files changed
+4
-34
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 12 | + | |
20 | 13 | | |
21 | 14 | | |
22 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| |||
This file was deleted.
This file was deleted.
0 commit comments