我想在YACC文件中添加结构工会,但我发现这个错误:结构工会C++ YACC
"error : member 'Info YYSTYPE ::info' with constructor not allowed in union "
%{
#include <cstdio>
#include <iostream>
using namespace std;
extern "C" int yylex();
extern "C" int yyparse();
extern "C" FILE *yyin;
struct Info{ int intval; float floatval; string stringval ;int type; }
void yyerror(const char *s);
%}
%union {
int ival;
float fval;
char *sval;
struct Info info;
}
错误告诉你几乎到底是什么问题:C++不允许你在联合中使用一个构造函数(非POD类型)。没有什么特别与yacc有关。 –
[...与构造函数不允许在联合问题中可能重复](http://stackoverflow.com/questions/6014717/with-constructor-not-allowed-in-union-problem) – Schore