Standard libnds headers including POSIX function that aren't defined
Posted: Sun Feb 12, 2023 5:47 am
Hi all! I'm working on a project that uses libnds/devkitARM, and I noticed some unexpected declarations coming from the `#include <nds.h>` include. For example, definitions for "ttyname", "getuid", and "setusershell" (among many others) are all included during compilation, although usages to these obviously result in a linker error if used. Tracing back the includes, it seems to come from the following sequence:
In my project, I can hack around this by putting `#define _SYS_UNISTD_H` and `typedef int ssize_t;`, or alternatively just `#define NDS_NAND_INCLUDE` to also prevent the DSi Nand function definitions from being included.
Not sure what much can be done about this from the devkitARM side, short of just manually providing a `ssize_t` typedef to remove the dependency on "unistd.h". Also not particularly high-priority, since any erroneously included function declaration will lead to a link error if actually used.
Also, separate issue, but seems like the `nds/arm9/nand.h` include should be gated by an `#ifdef`, no? I suppose it's already compiled into the static library, and presumably has graceful fallback if called on an NDS.
Code: Select all
In file included from /opt/devkitpro/libnds/include/nds.h:280:
In file included from /opt/devkitpro/libnds/include/nds/arm9/nand.h:32:
In file included from /opt/devkitpro/devkitARM/arm-none-eabi/include/unistd.h:4:
/opt/devkitpro/devkitARM/arm-none-eabi/include/sys/unistd.h
Not sure what much can be done about this from the devkitARM side, short of just manually providing a `ssize_t` typedef to remove the dependency on "unistd.h". Also not particularly high-priority, since any erroneously included function declaration will lead to a link error if actually used.
Also, separate issue, but seems like the `nds/arm9/nand.h` include should be gated by an `#ifdef`, no? I suppose it's already compiled into the static library, and presumably has graceful fallback if called on an NDS.