Bug 199316 - defining _POSIX_SOURCE breaks builds
Summary: defining _POSIX_SOURCE breaks builds
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: flex
Version: rawhide
Hardware: All
OS: Linux
high
high
Target Milestone: ---
Assignee: Petr Machata
QA Contact:
URL:
Whiteboard:
: 199320 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-07-18 20:38 UTC by Jason Vas Dias
Modified: 2015-05-05 01:32 UTC (History)
2 users (show)

Fixed In Version: FC-6
Clone Of:
Environment:
Last Closed: 2006-07-19 05:00:12 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Jason Vas Dias 2006-07-18 20:38:17 UTC
Description of problem:

The latest flex-2.5.4a version unconditionally defines _POSIX_SOURCE to 1
in the skeleton #defines of all flex generated code, with the new
flex-2.5.4a-posix.patch:

--- flex-2.5.4/skel.c   2006-07-14 15:30:18.000000000 +0200
+++ flex-2.5.4-pm/skel.c        2006-07-14 15:29:43.000000000 +0200
@@ -14,6 +14,8 @@ const char *skel[] = {
   "#define YY_FLEX_MINOR_VERSION 5",
   "",
   "%-",
+  "/* Use posix source, to silent c99 warnings about fileno. */",
+  "#define _POSIX_SOURCE 1",
   "#include <stdio.h>",
   "#include <unistd.h>",
   "%*",


I think this is a VERY bad idea, as it breaks builds that for instance 
use such constructs as 'u_long' ( if _POSIX_SOURCE is defined, then
_USE_BSD is undefined, and the 'u_long' typedef is not defined by 
sys/types.h ).

This has broken the dhcpv6 build so far (and possibly others) - I
now have to patch dhcpv6's flex code to '#undef _POSIX_SOURCE'
before including sys/types.h in order to get it to build.

I don't think avoiding any compiler warning warrants such a major
API change as defining _POSIX_SOURCE=1 by default - couldn't the code
be reworked so that the C99 compiler doesn't complain ?


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

How reproducible:
100%

Steps to Reproduce:
Generate any flex code that uses the 'u_long' type

  
Actual results:
The code won't compile

Expected results:
Code should be able to use flex and u_long and still compile.

Comment 1 Petr Machata 2006-07-18 21:11:23 UTC
So without posix, you don't have fileno.  With posix, you don't have u_long. 
This or that way you end up with invalid source.  I can't drop using fileno, as
someone else would miss /that/.

Hmm, ok, imposing posix because of warning is too much of a restriction.  I'm
reverting the patch and will look for better workaround to that warning.

Comment 2 Petr Machata 2006-07-18 21:20:38 UTC
*** Bug 199320 has been marked as a duplicate of this bug. ***

Comment 3 Petr Machata 2006-07-19 05:00:12 UTC
Just did a build. Should be available later today for fc4/5/6.

Comment 4 Jason Vas Dias 2006-07-19 06:45:44 UTC
Thank you! The new flex-2.5.4a-41.fc6 version now works OK.


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