From 7e1b36e8985f2dd88646049661080eac065d36f9 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 3 Aug 2020 12:18:47 -0700 Subject: scanner: issue with header. Flex-generated scanners contain a #include 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 right after "config.h", if HAVE_UNISTD_H is defined. Define YY_NO_UNISTD_H to suppress the flex-generated #include. --- parser.l | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/parser.l b/parser.l index 93b83fc5..9d2ecd4f 100644 --- a/parser.l +++ b/parser.l @@ -35,6 +35,9 @@ #include #include #include "config.h" +#if HAVE_UNISTD_H +#include +#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"); \ -- cgit v1.2.3