%union in Bison

"Davide Rizzo" <belgioioso@libero.it>
12 Jan 2003 17:40:10 -0500

          From comp.compilers

Related articles
%union in Bison belgioioso@libero.it (Davide Rizzo) (2003-01-12)
Re: %union in Bison haberg@math.su.se (2003-01-17)
Re: %union in Bison j.rauser@science-factory.com (James Rauser) (2003-01-17)
Re: %union in Bison wicklund@eskimo.com (2003-01-17)
Re: %union in Bison basireddym@rediffmail.com (2003-01-25)
| List of all articles for this month |

From: "Davide Rizzo" <belgioioso@libero.it>
Newsgroups: comp.compilers
Date: 12 Jan 2003 17:40:10 -0500
Organization: [Infostrada]
Keywords: yacc, C++, comment
Posted-Date: 12 Jan 2003 17:40:10 EST

I need to use a customized type definition in Bison; I tried the following
      #include <string>

      string str;
      int integer;

but even if Bison correctly generate C code defining YYSTYPE with
typedef union{
      string str;
      int integer;
when I try to compile (Dev-C++ gcc compiler) I get a "member `class string
{anonymous union}::str' with constructor not allowed in union" error. I
suppose I can't use classes in unions, but I would like to be sure of that
(or is it just a string particular mood?)
thanx for your help, regards
reply at belgioioso@libero.it
[Bison generates C code, not C++ code. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.