hermit-os / hermit-os/newlib

`__STRICT_ANSI__` inhibits `_POSIX_C_SOURCE`

Open
#177 2 comments 0 reactions 1 assignee Claimed by @mkroening View on GitHub
Dominant language
C
Stars
0
Forks
8
PR merge metrics
No merged PRs in 30d

Description

When specifying a c++ standard, we apparently unset/don't set `_DEFAULT_SOURCE`/`_POSIX_SOURCE`/`_POSIX_C_SOURCE` (not sure what exactly happens). This leads to the functions gated by `_POSIX_C_SOURCE` not being available.

### Minimal reproducible example:

```c++
#include
int main() {
readlink("asdf", NULL, 0);
}
```

```sh
> g++ -o main main.cpp -std=c++11
# Succeeds

> docker run --rm -v .:/mnt:z -w /mnt ghcr.io/hermit-os/hermit-gcc:x86_64 x86_64-hermit-g++ -o main main.cpp -L/mnt
# Succeeds

> docker run --rm -v .:/mnt:z -w /mnt ghcr.io/hermit-os/hermit-gcc:x86_64 x86_64-hermit-g++ -o main main.cpp -std=c++11 -L/mnt
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
main.cpp: In function 'int main()':
main.cpp:8:5: error: 'readlink' was not declared in this scope
8 | readlink("asdf", NULL, 0);
| ^~~~~~~~
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.