flex 2.5.31

Tobias Gasser tg at ebp-gasser.ch
Fri Sep 10 11:20:15 PDT 2004


Bryan Kadzban schrieb:

> On Fri, Sep 10, 2004 at 05:36:18PM +0200, Tobias Gasser wrote:
> 
>>now flex has errors.
>>
>>with CFLAGS="-march=i586" i get errors.
>>with CFLAGS="-march=i586 -O{,1,2,3,s}" it's fine
>>thus any value is fine, but none not!
>>
>>i don't understand why i get these errors:
>>
>>main.c: In function 'main'
>>main.c:201: error: 'LC_MESSAGES' undeclared (first use in this function)
>>main.c:202: error: 'LC_CTYPE' undeclared (first use in this function)
> 
> 
> I get the same errors when setting CFLAGS to -march=i586 -O0.
> 
> The -march setting doesn't seem to matter (I also get the error when
> using i686, athlon-xp, etc.).  It's the -O0 setting that breaks it.
> 
> I was running tests by doing a:
> 
> make main.o CFLAGS="-O0 -E"
> 
> and:
> 
> make main.o CFLAGS="-O1 -E"
> 
> (Of course I renamed main.o in between these runs.)
> 
> When I ran it with -O0, the preprocessed file used LC_MESSAGES and
> LC_CTYPE in the main function.
> 
> When I ran it with -O1, the preprocessed file used __LC_MESSAGES and
> __LC_CTYPE in the main function.
> 
> That's the problem, I think.  Somewhere in the headers, there's a
> #define LC_MESSAGES __LC_MESSAGES, and that's getting skipped with a -O
> level of zero.
> 
> And sure enough: flex's gettext.h header includes <libintl.h>.  This
> file (as of gettext 0.12.1 at least -- that's the only version I have to
> test) only includes <locale.h> if __OPTIMIZE__ is defined.  And locale.h
> is what contains the #define LC_MESSAGES __LC_MESSAGES line.
> 
> The simple fix is to always use at least -O1 (gettext's default Makefile
> uses -g -O2 as its CFLAGS if you don't have them set in the environment
> at configure time).  The slightly more complicated fix is to edit flex's
> gettext.h file to also #include <locale.h> right after #include'ing
> <libintl.h> (in the #if ENABLE_NLS branch).

ok. so i'll use -O2 to have the default value.
maybe we should add a comment in the book to have a -O2 in CFLAGS when 
CFLAGS is defined explaining what happens otherwise.

at least i now understand what happens.

thanks for your help.
tobias



More information about the lfs-dev mailing list