Bug 195687

Summary: Generated code does not compile cleanly as C99
Product: [Fedora] Fedora Reporter: Pawel Salek <pawsa-gpa>
Component: flexAssignee: Petr Machata <pmachata>
Status: CLOSED RAWHIDE QA Contact:
Severity: low Docs Contact:
Priority: medium    
Version: 5CC: mnewsome
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-07-14 13:50:49 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pawel Salek 2006-06-16 16:09:52 UTC
Description of problem:
Code generated by flex generates warnings when C99 support of gcc is enabled:

Version-Release number of selected component (if applicable):
flex-2.5.4a-37.4

How reproducible:
always

Steps to Reproduce:
1. Create file:
%{
#define EOFTAG 1
%}
eoftag           ^EOF$
%%
{eoftag}          return EOFTAG;

2. Compile 
$ flex flextest.l && gcc -c -std=c99 lex.yy.c
lex.yy.c: In function âyy_init_bufferâ:
lex.yy.c:1219: warning: implicit declaration of function âfilenoâ

Additional info:
adding #define _POSIX_SOURCE 1
at the top of the generated file silences the warning.

Comment 1 Petr Machata 2006-07-12 10:00:04 UTC
This bugs me, too, but I have no idea how to fix it.

Flex needs fileno to find out, if it's attached to terminal, in which case it
uses interactive mode.  So either we give up interactive mode, or we find out a
way how to do isatty on FILE*.  Now giving up interactive mode is fine for me,
but I'm afraid it's not very good general solution.

Comment 2 Petr Machata 2006-07-12 10:16:15 UTC
But thinking about it, adding _POSIX_SOURCE would probably be the right solution.

Comment 3 Petr Machata 2006-07-14 13:50:49 UTC
The patch is in rawhide, and I've also pushed it for fc5.

Comment 4 Simon Wilkinson 2006-07-18 21:17:27 UTC
This fix breaks code which expects to be able to use BSD symbols (such as u_short) from within code 
included by the lexer. See bug #199320.