readline: define _XOPEN_SOURCE at the top of files

It is a requirement to define feature_test_macros(7) as soon as possible
before including any files, otherwise the headers may not allow further
configuration, as reconfiguration maybe denied.  You need to pick the
standard you wish to work with for the compilation unit (the file).

This can be seen with an error for lack of symbol `wcwidth()` from wchar.h

Moving the order slightly fixes the compile failure issue.
See feature_test_macros(7) for more info.

GCC14 --without-tk --without-tcl (without system libreadline-dev)
This commit is contained in:
Darryl L. Miles 2024-10-02 06:59:00 +01:00 committed by Tim Edwards
parent 54f49829f2
commit 932deeaf2d
2 changed files with 4 additions and 1 deletions

View File

@ -21,6 +21,8 @@
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#define _XOPEN_SOURCE /* See feature_test_macros(7) */
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
@ -41,7 +43,6 @@
#include <stdio.h>
#define _XOPEN_SOURCE /* See feature_test_macros(7) */
#include <wchar.h>
/* System-specific feature definitions and include files. */

View File

@ -25,6 +25,8 @@
# include <config.h>
#endif
#define _XOPEN_SOURCE /* See feature_test_macros(7) */
#include <sys/types.h>
#include <fcntl.h>
#include <wchar.h>