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

Re: flex++ and C++ compliance



Rob Weir sez:
} On Thu, Feb 13, 2003 at 11:23:16AM -0500, Gregory Seidman wrote:
} > I'm trying to determine whether flex++ produces standards-compliant
} > C++. It seems that it very nearly does, except that
} > /usr/include/FlexLexer.h refers to std::istream and std::ostream
} > without the std:: prefix. This is as of 2.5.4a-30 (current unstable),
} > however; 2.5.4a-29 was still using iostream.h. I downloaded 2.5.4a from
} > ftp.gnu.org and its FlexLexer.h is still using iostream.h.
} > 
} > Does this mean that only Debian's (unstable) version of flex++ is
} > properly C++ compliant (and still not quite)? Will the changes get back
} > into the primary branch?
} 
} The Debian maintainer has probably already sent the patches upstream to
} GNU; it probably has a slow release cycle though, which is why it hasn't
} shown up yet.

Mm. I'm actually a little confused about this. At ftp.gnu.org, flex is in
the non-gnu directory. I think that means that it is part of the GNU
project, but not maintained by them. Or maybe the reverse. I'm not sure.

} > My motivation here is to be able to document which version of flex++
} > some software requires. Right now I can use any version, but I have my
} > own flex.skl and FlexLexer.h which are heavily modified. I'd rather be
} > able to document a reliance on an authoritative version.
} 
} If you've managed to get full ISO C++ compliance working, then send your
} patch to both the Debian maintainer and GNU, they will love you for it :)

It's absurdly easy, and doesn't require modifying flex's code at all.
FlexLexer.h needs to include iosfwd instead of iostream.h, then sed
's/[io]stream/std::&/g'. The flex.skl needs to replace

#include <iostream.h>

with

#include <iostream>
using namespace std;

I'm pretty appalled this hasn't been done yet. The real problem back when I
made my own modified version was that FlexLexer.h forward declared istream
and ostream as classes, when they are (now) really typedefs of specialized
basic_istream and basic_ostream. They have at least fixed that so that flex
2.5.4 merely causes g++ 3.2 to complain bitterly about using backward
compatibility headers. I think I may be able to document that 2.5.4 or
higher is required, even with warnings.

As for why I haven't submitted the patch, there are two reasons: 1) there's
no clear process to do so, and 2) it's so utterly trivial. If you or anyone
else would like to do what I described above and send the patch to the
appropriate people, you are more than welcome to. Don't even feel obligated
to mention my name.

} -- Rob Weir <rweir@ertius.org>
} http://ertius.org/
--Greg



Reply to: