Re: %union in Bison (manohar)
25 Jan 2003 00:45:35 -0500

          From comp.compilers

Related articles
%union in Bison (Davide Rizzo) (2003-01-12)
Re: %union in Bison (2003-01-17)
Re: %union in Bison (James Rauser) (2003-01-17)
Re: %union in Bison (2003-01-17)
Re: %union in Bison (2003-01-25)
| List of all articles for this month |

From: (manohar)
Newsgroups: comp.compilers
Date: 25 Jan 2003 00:45:35 -0500
References: 03-01-048
Keywords: C++, yacc
Posted-Date: 25 Jan 2003 00:45:35 EST

"Davide Rizzo" <> wrote
> [ putting a C++ "string" type in a bison %union doesn't work]
> 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
> Davide
> reply at
> [Bison generates C code, not C++ code. -John]

hi friend,
                    As Bison doesn't support c++ string(which consists constructor),
the best way would be declare pointer to the string and do allocate memory
whereever needed.

declare YYSTYPE as
typedef union{
        string *str;
        int integer;


Post a followup to this message

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