public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: Compiling Bison-generated parsers with MS VC++?
@ 1998-10-14  7:39 Steven J. Zeil
  0 siblings, 0 replies; 6+ messages in thread
From: Steven J. Zeil @ 1998-10-14  7:39 UTC (permalink / raw)
  To: gnu-win32

Well, my previous message got garbled somewhere along the way between my
mailer and the GnuWin32 digest.  Since I follow this group via the digest,
I'm not sure how it looked on the actual mailing list, but the digested
message is missing the phrase equivalent to:
    left-angle-bracket in.h right-angle-bracket
in 2 places (removed by a mailer as a bad HTML tag?)


> VC++ declares alloca in , so I have found it necessary to add
                         |
                     missing:  in.h within angle brackets
> an #include for that file to the declarations section of my bison 
> inputs.
>
> I have also found a problem with isatty occurring in scanners
> generated by some versions of flex. The VC++ header for this does not 
> put it in an "extern "C" {}", leading to errors when the program
> is linked.
>
> So I wind up adding the following:
> #ifdef _MSC_VER
> #include 
            |
          missing:  in.h within angle brackets
> extern "C" {
>   int isatty (int handle);
> }
> #endif
> to cover both problems.

-------------------------
Steven J. Zeil
Dept. of Computer Science        http://www.cs.odu.edu/~zeil
Old Dominion University
Norfolk, VA 23529

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Compiling Bison-generated parsers with MS VC++?
@ 1998-10-13  0:20 Steven J. Zeil
  0 siblings, 0 replies; 6+ messages in thread
From: Steven J. Zeil @ 1998-10-13  0:20 UTC (permalink / raw)
  To: gnu-win32

>>/cygnus/b19/share/bison.simple(333) : error C2065: 'alloca' : undeclared
>>identifier
>>/cygnus/b19/share/bison.simple(387) : error C2065: 'yylex' : undeclared
>>identifier
>
>SInce VC++ is a C++ compiler, both yyerror and yylex prototypes have to
>be declared before they are used (at the top of the Bison grammar. I
>don't
>recall having a problem with alloca, but I'll try to check that out.

VC++ declares alloca in <malloc.h>, so I have found it necessary to add
an #include for that file to the declarations section of my bison inputs.

I have also found a problem with isatty occurring in scanners
generated by some versions of flex. The VC++ header for this does not 
put it in an "extern "C" {}", leading to errors when the program is
linked.

So I wind up adding the following:
#ifdef _MSC_VER
#include <malloc.h>
extern "C" {
  int isatty (int handle);
}
#endif
to cover both problems.

-------------------------
Steven J. Zeil

Dept. of Computer Science        http://www.cs.odu.edu/~zeil
Old Dominion University
Norfolk, VA 23529

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Compiling Bison-generated parsers with MS VC++?
@ 1998-10-08 21:43 Gilles Depeyrot
  0 siblings, 0 replies; 6+ messages in thread
From: Gilles Depeyrot @ 1998-10-08 21:43 UTC (permalink / raw)
  To: Christopher David Hundhausen, gnu-win32

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1723 bytes --]

Hi Christopher,

I use several Bison/Flex parser/lexers in one of my Windows applications.
This should be absolutely no trouble since both Bison and Flex generate
portable C code. You do have to create an empty unistd.h include file
to get things to compile correctly.


Le (the) 7/10/98 18:04, Christopher David Hundhausen a écrit (wrote) :

>The next step is to get VC++ to compile a bison-generated parser that
>makes use of MFC classes.  Does anyone have any suggestions on
>how to get this to work?  At present, my compilation results in
>the following error messages:
>
>/cygnus/b19/share/bison.simple(327) : error C2065: 'yyerror' : undeclared
>identifier
>/cygnus/b19/share/bison.simple(333) : error C2065: 'alloca' : undeclared
>identifier
>/cygnus/b19/share/bison.simple(387) : error C2065: 'yylex' : undeclared
>identifier

SInce VC++ is a C++ compiler, both yyerror and yylex prototypes have to be
declared before they are used (at the top of the Bison grammar. I don't
recall having a problem with alloca, but I'll try to check that out.

>Once I get the parser to compile, what will I need to do to get
>everything to link properly with my MFC app?  Is there a gnu-win32
>object file that I need to include in the link? Does anyone have any
>advice?

Since you are compiling with VC++, you don't need any Gnu-Win32 libraries.
The VC++ libraries contain all of the C entry points used by Bison and Flex.

Cheers,
Gilles


Gilles Depeyrot                    < mailto:Gilles.Depeyrot@wanadoo.fr >
                             < http://perso.wanadoo.fr/gilles.depeyrot >

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: Compiling Bison-generated parsers with MS VC++?
@ 1998-10-08 21:43 Michael Czapski
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Czapski @ 1998-10-08 21:43 UTC (permalink / raw)
  To: 'Christopher David Hundhausen', gnu-win32

On Thursday, October 08, 1998 2:04 AM, Christopher David Hundhausen 
[SMTP:chundhau@cs.uoregon.edu] wrote:
> I've used VC++ (v 5.0) to successfully compile a flex-generated lexical
> analyzer (lex.yy.cpp).  I did this by using the trick of creating a dummy
> (empty)  uinstd.h file (this trick was recently suggested on this mailing
> list).
>
> The next step is to get VC++ to compile a bison-generated parser that
> makes use of MFC classes.  Does anyone have any suggestions on
> how to get this to work?  At present, my compilation results in
> the following error messages:
>
> /cygnus/b19/share/bison.simple(327) : error C2065: 'yyerror' : undeclared
> identifier
> /cygnus/b19/share/bison.simple(333) : error C2065: 'alloca' : undeclared
> identifier
> /cygnus/b19/share/bison.simple(387) : error C2065: 'yylex' : undeclared
> identifier
>
> Once I get the parser to compile, what will I need to do to get
> everything to link properly with my MFC app?  Is there a gnu-win32
> object file that I need to include in the link? Does anyone have any
> advice?
>
> Please send you responses directly to me (chundhau@cs.uoregon.edu), in
> addition to posting them to the list.
>
> Thanks in advance,
> :-)Chris
>
> -
Hello Chris,

I did a project utilizing both but I did not have a need to create a dummy 
unistd.h.

Presumably you have a yyerror in your source.l as void yyerror(char *message) ? 
 If not, you will need one, if only an empty one. Once you have the yyerror 
declare it as 'extern void yyerror(char *message)' in your source.y or a header 
file you share between your source.l and source.y, if you have one.
Similarly, declare yylex in your souce.y as extern int yylex( void ).
In so far as the alloca issue is concerned you can do a
#define YY_ALWAYS_INTERACTIVE 1
which will take care of that, although I don't see how you got that in the 
first place.  I have used bith flex and bison in a source-portable app that 
builds with MS VC++ 5.0, egcs 1.0.2 on cygwin32, Linux and OpenVMS and only 
Linux and OpenVMS had an issue with the alloca (missing that is).

That's what I did in a C environment.  Sorry, I don't grok c++, just plain c.
------------------
Cheers ...
Michael Czapski


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: Compiling Bison-generated parsers with MS VC++?
@ 1998-10-08 15:29 Kubat, Karel
  0 siblings, 0 replies; 6+ messages in thread
From: Kubat, Karel @ 1998-10-08 15:29 UTC (permalink / raw)
  To: 'Christopher David Hundhausen', gnu-win32

Chris,

> error messages:
> /cygnus/b19/share/bison.simple(327) : error C2065: 'yyerror' 
> : undeclared
> identifier
> /cygnus/b19/share/bison.simple(333) : error C2065: 'alloca' : 
> undeclared
> identifier
> /cygnus/b19/share/bison.simple(387) : error C2065: 'yylex' : 
> undeclared
> identifier

You need to declare your own yyerror() routine, if memory serves me, it
returns an int and requires an int as argument. Same goes for yylex() --
that comes from your flex-generated file. 

alloca() is often a problem, I've seen sources of that but I dunno where
anymore...

Cheers, K
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Compiling Bison-generated parsers with MS VC++?
@ 1998-10-07  9:04 Christopher David Hundhausen
  0 siblings, 0 replies; 6+ messages in thread
From: Christopher David Hundhausen @ 1998-10-07  9:04 UTC (permalink / raw)
  To: gnu-win32

I've used VC++ (v 5.0) to successfully compile a flex-generated lexical
analyzer (lex.yy.cpp).  I did this by using the trick of creating a dummy
(empty)  uinstd.h file (this trick was recently suggested on this mailing
list).

The next step is to get VC++ to compile a bison-generated parser that
makes use of MFC classes.  Does anyone have any suggestions on
how to get this to work?  At present, my compilation results in
the following error messages:

/cygnus/b19/share/bison.simple(327) : error C2065: 'yyerror' : undeclared
identifier
/cygnus/b19/share/bison.simple(333) : error C2065: 'alloca' : undeclared
identifier
/cygnus/b19/share/bison.simple(387) : error C2065: 'yylex' : undeclared
identifier

Once I get the parser to compile, what will I need to do to get
everything to link properly with my MFC app?  Is there a gnu-win32
object file that I need to include in the link? Does anyone have any
advice?

Please send you responses directly to me (chundhau@cs.uoregon.edu), in
addition to posting them to the list.

Thanks in advance,
:-)Chris

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1998-10-14  7:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-14  7:39 Compiling Bison-generated parsers with MS VC++? Steven J. Zeil
  -- strict thread matches above, loose matches on Subject: below --
1998-10-13  0:20 Steven J. Zeil
1998-10-08 21:43 Michael Czapski
1998-10-08 21:43 Gilles Depeyrot
1998-10-08 15:29 Kubat, Karel
1998-10-07  9:04 Christopher David Hundhausen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).