Bug 195687 - Generated code does not compile cleanly as C99
Summary: Generated code does not compile cleanly as C99
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: flex
Version: 5
Hardware: i386
OS: Linux
medium
low
Target Milestone: ---
Assignee: Petr Machata
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-06-16 16:09 UTC by Pawel Salek
Modified: 2015-05-05 01:32 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-07-14 13:50:49 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

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.



Note You need to log in before you can comment on or make changes to this bug.