Skip to content

Commit

Permalink
do not define internal libc macros
Browse files Browse the repository at this point in the history
macros like `__USE_XOPEN` are internal to libc and shouldn't be defined
by the user. the proper macro to define is `_XOPEN_SOURCE`.

defining `_XOPEN_SOURCE_EXTENDED` shouldn't be needed anymore since
according to the manpage (`man feature_test_macros`):

> defining _XOPEN_SOURCE with a value of 500 or greater produces the same
> effects as defining _XOPEN_SOURCE_EXTENDED.

but define it anyways, just in case.

also define _BSD_SOURCE and _DEFAULT_SOURCE
  • Loading branch information
N-R-K committed Jul 1, 2023
1 parent 8fdf35e commit b5e9639
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/nnn.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@
*/

#define _GNU_SOURCE
#define _BSD_SOURCE
#define _DEFAULT_SOURCE
#define _FILE_OFFSET_BITS 64 /* Support large files on 32-bit glibc */
#define _XOPEN_SOURCE_EXTENDED
#undef _XOPEN_SOURCE
#define _XOPEN_SOURCE 700L
#ifndef NCURSES_WIDECHAR
#define NCURSES_WIDECHAR 1
#endif

#if defined(__linux__) || defined(MINGW) || defined(__MINGW32__) \
|| defined(__MINGW64__) || defined(__CYGWIN__)
Expand Down Expand Up @@ -57,19 +65,6 @@
#endif
#include <sys/wait.h>

#ifdef __linux__ /* Fix failure due to mvaddnwstr() */
#ifndef NCURSES_WIDECHAR
#define NCURSES_WIDECHAR 1
#endif
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \
|| defined(__APPLE__) || defined(__sun)
#ifndef _XOPEN_SOURCE_EXTENDED
#define _XOPEN_SOURCE_EXTENDED
#endif
#endif
#ifndef __USE_XOPEN /* Fix wcswidth() failure, ncursesw/curses.h includes whcar.h on Ubuntu 14.04 */
#define __USE_XOPEN
#endif
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
Expand Down Expand Up @@ -99,9 +94,6 @@
#include <unistd.h>
#include <stddef.h>
#include <stdalign.h>
#ifndef __USE_XOPEN_EXTENDED
#define __USE_XOPEN_EXTENDED 1
#endif
#include <ftw.h>
#include <pwd.h>
#include <grp.h>
Expand Down

0 comments on commit b5e9639

Please sign in to comment.