Subject: Re: Compiling Bison-generated parsers with MS VC++?
From: [email-masked] (Steven J. Zeil)

13 Oct 1998 08:28:18 -0700
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
To: [email-masked]

>>/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
"[email-masked]" with one line of text: "help".