Page 1 of 1

Standard libnds headers including POSIX function that aren't defined

Posted: Sun Feb 12, 2023 5:47 am
by jahs-tech
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:

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
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.

Re: Standard libnds headers including POSIX function that aren't defined

Posted: Tue Apr 18, 2023 1:37 pm
by WinterMute
This is just a normal consequence of headers that support a variety of platforms and isn't anything worth worrying about. We tend to implement functions as and when we need them.