Standard libnds headers including POSIX function that aren't defined

Post Reply
jahs-tech
Posts: 2
Joined: Sun Feb 12, 2023 12:46 am

Standard libnds headers including POSIX function that aren't defined

Post by jahs-tech » 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:

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.

WinterMute
Site Admin
Posts: 1859
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

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

Post by WinterMute » Tue Apr 18, 2023 1:37 pm

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.
Help keep devkitPro toolchains free, Donate today

Personal Blog

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests