summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-08-03 12:18:47 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-08-03 12:18:47 -0700
commit10a9dd2304c8187b5e4ec958633580ca35d3bf2b (patch)
tree28ddd4795982ad6bc7c53a1654ec92ba7ad29be2
parentbc2ac36079f3d349102f665aebc41d8a69c3ee14 (diff)
downloadtxr-10a9dd2304c8187b5e4ec958633580ca35d3bf2b.tar.gz
txr-10a9dd2304c8187b5e4ec958633580ca35d3bf2b.tar.bz2
txr-10a9dd2304c8187b5e4ec958633580ca35d3bf2b.zip
scanner: issue with <unistd.h> header.
Flex-generated scanners contain a #include <unistd.h> directive, whose purpose seems to be to ensure that isatty is declared. This #include is in a bad place, long after all our headers have been declared. We define macros in lib.h and elsewhere that can interfere with system headers. The Homebrew distro people have run into this problem on OS/X. Our lib.h defines a "noreturn" macro (that should arguably be named NORETURN, to match the style for INLINE). A "noreturn" macro interferes with __attribute__((noreturn)) syntax in system headers. Our main strategy for not causing that problem is to include all system headers first, before local headers. * parser.l: include <unistd.h> right after "config.h", if HAVE_UNISTD_H is defined. Define YY_NO_UNISTD_H to suppress the flex-generated #include.
-rw-r--r--parser.l5
1 files changed, 5 insertions, 0 deletions
diff --git a/parser.l b/parser.l
index 93b83fc5..9d2ecd4f 100644
--- a/parser.l
+++ b/parser.l
@@ -35,6 +35,9 @@
#include <wchar.h>
#include <signal.h>
#include "config.h"
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#include "lib.h"
#include "gc.h"
#include "stream.h"
@@ -46,6 +49,8 @@
#include "parser.h"
#include "txr.h"
+#define YY_NO_UNISTD_H
+
#define YY_INPUT(buf, result, max_size) \
do { \
val self = lit("parser"); \