Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH] C++ fix for flex

0 views
Skip to first unread message

Craig Rodrigues

unread,
Sep 7, 2002, 11:55:40 PM9/7/02
to
Hi,

As I am fixing some of the C++ ports for GCC 3.2, I found a problem with lex.
The following patch is required for lex to generate code which
can compile with GCC 3.2. It applies to /usr/src/usr.bin/lex


--- flex.skl.orig Sat Sep 7 23:44:38 2002
+++ flex.skl Sat Sep 7 23:45:06 2002
@@ -26,7 +26,8 @@

#include <stdlib.h>
%+
-class istream;
+#include <iosfwd>
+using namespace std;
%*
#include <unistd.h>


For Standard C++, you cannot forward declare istream as:
class istream;

because in Standard C++, istream is a typedef for a template:
typedef basic_istream<char> istream;


The correct fix is to include <iosfwd>. Under gcc 2.95,
<iosfwd> forward declares istream as "class istream;" and
under gcc 3.2, <iosfwd> forward declares istream as the typedef.

The "using namespace std;" is required because in gcc 3.2, istream
is in the std namespace. In gcc 2.95, this line will be benign.
--
Craig Rodrigues
http://www.gis.net/~craigr
rod...@attbi.com

To Unsubscribe: send mail to majo...@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message

David O'Brien

unread,
Sep 8, 2002, 10:59:19 PM9/8/02
to
On Sat, Sep 07, 2002 at 11:55:08PM -0400, Craig Rodrigues wrote:
> Hi,
>
> As I am fixing some of the C++ ports for GCC 3.2, I found a problem with lex.
> The following patch is required for lex to generate code which
> can compile with GCC 3.2. It applies to /usr/src/usr.bin/lex

Committed. Thanks!

0 new messages