delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/09/10/23:02:45

From: "Jim Fischer" <jfischer AT calpoly DOT edu>
Newsgroups: comp.lang.c++,comp.os.msdos.djgpp
Subject: Re: passing istringstream as istream in param
Date: Sun, 10 Sep 2000 19:32:32 -0700
Organization: Cal Poly
Lines: 56
Message-ID: <8phi1k$9g0$1@cscnews.csc.calpoly.edu>
References: <f6Yt5.55$t42 DOT 3484 AT nsw DOT nnrp DOT telstra DOT net>
NNTP-Posting-Host: synthis.ee.calpoly.edu
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Mostyn Lee" <mostyn AT ibc DOT com DOT au DOT SPAM> wrote in message
news:f6Yt5.55$t42 DOT 3484 AT nsw DOT nnrp DOT telstra DOT net...

> i used flex to generate a parser c++ class, and this class requires a
> istream * as its parameter
>
> yyFlexLexer::yyFlexLexer( istream* arg_yyin, ostream* arg_yyout )
>
> i need to parse from a character buffer, and have created a istringstream.
> the object will not accept the istringstream as a valid type parameter.
> i am using visual c++ 6.0 with a GNU flex generated class
>
>
> #include <iostream>
> #include <string>
> #include <sstream>
> // ....
> using namespace std;
> // ....
>
>   string constructstring = ReturnsAString();
>   istringstream lexingstream(constructstring);
>   lexingstream << constructstring;
>
>    yyFlexLexer myyyFlexLexer(&lexingstream, std::cout);
> // ....
>
> gets the error :
> error C2664: '__thiscall yyFlexLexer::yyFlexLexer(class istream *,class
> ostream *)' : cannot convert parameter 1 from 'class
> std::basic_istream<char,struct std::char_traits<char> > *' to 'class
istream
> *'

Possible answer #1) Sounds like VC++ is broken. You might visit the VC++ web
site to see if there are any patches/updates (service packs) available for
the specific version of VC++ you are using...

Possible answer #2) Is the flex-generated code using the pre-ANSI
(deprecated) iostream classes -- i.e., <iostream.h> -- or the new
ANSI-compliant iostream classes -- i.e., <iostream> ???  There are some
significant differences between the pre-ANSI and ANSI iostream classes --
i.e., the two are not 100% compatible. So you might want to check your
source files (particularly the ones that flex generates) to see if your
program is specifying both the pre-ANSI library (headers like "<xxx.h>") and
the ANSI library (headers like "<xxx>") -- and not just the iostream
headers. If so, then you need to fix your code so that it uses either the
pre-ANSI library exclusively, or the ANSI library exclusively, and not both
at the same time.


Jim



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019