bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

#if !_GL_CONFIG_H_INCLUDED breaks flex generated lexers, FYI


From: Paul J. Lucas
Subject: #if !_GL_CONFIG_H_INCLUDED breaks flex generated lexers, FYI
Date: Thu, 13 Apr 2023 10:21:57 -0700

Hello -

This recent commit:

https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commit;h=8ad7bc671475d3291df10a1a1d64fddfd30e5175

renders Flex generated lexers uncompilable. If you use GnuLib, you're using 
wrappers around standard headers like stdio.h. The recent commit added lines to 
such wrappers like this:

#if !_GL_CONFIG_H_INCLUDED
 #error "Please include config.h first."
#endif

The problem is a Flex-generated lexer's .c file has:

/* begin standard C headers. */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>

generated near the top and the project's include path is set to pick up the 
wrapper headers first — and the lexer's .c file doesn't have:

#include "config.h"

before the include of the wrapper headers, so it complains.

IMHO, this is a problem with Flex, not GnuLib.  Flex should have a mechanism to 
insert code at the top of the generated lexer like Bison’s "%code top” 
directive.

So this is just an FYI that the aforementioned commit can break machine 
generated C code.

- Paul




reply via email to

[Prev in Thread] Current Thread [Next in Thread]