Mail Archives: djgpp/2000/09/10/23:02:45
"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 -