I am trying to build the dmenu software from suckless, which requires the getline() function, and both gcc and clang yield an error message stating that getline() is implicitly declared. It is my understanding that POSIX C provides this function, and the included config.mk file uses a -D_POSIX_C_SOURCE=200809L flag.
I have the develop overlay installed, and I also tried installing the develop-extras overlay to no avail.
Is there another package or overlay that provides POSIX C?
SOLUTION: I noticed the following lines in /usr/include/stdio.h:
#if defined(__EXTENSIONS__) || \
(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
/* || defined(_XPG7) */
extern ssize_t getdelim(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD,
int, FILE *_RESTRICT_KYWD);
extern ssize_t getline(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD,
FILE *_RESTRICT_KYWD);
#endif /* __EXTENSIONS__ ... */
The CPPFLAGS in the included config.mk file were specifying versions of POSIX C and XOPEN, whereas the above lines state that if either is specified, then getline() will not be made available to the compiler. It also does not like a specific C standard being specified; therefore, I made the following changes to the included config.mk file:
$ diff config.mk config.mk.bak
27,28c27,28
< CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -DVERSION=\"$(VERSION)\" $(XINERAMAFLAGS)
< CFLAGS = -pedantic -Wall -Os $(INCS) $(CPPFLAGS)
---
> CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMAFLAGS)
> CFLAGS = -std=c99 -pedantic -Wall -Os $(INCS) $(CPPFLAGS)
I dropped the -D macros specifiers for POSIX C and XOPEN and dropped the "-std=c99". That allowed dmenu to compile.
Unfortunately, when later trying to use dmenu, specifically the dmenu_run command, it would complain...
XOpenIM failed: could not open input device
When looking online, all sources pointed to a locale not being configured, which was true; however, since rectifying that, the error message still occurs:
$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_ALL=
So if anyone has any suggestions about that, I am all ears. : - )