Hi I was using a vector inside a union. Is this legal?
Thank you,
Printable View
Hi I was using a vector inside a union. Is this legal?
Thank you,
Why do you want to do that in the first place?
To answer the strict question, any object that has a non-trivial constructor cannot be in a union, and I believe std::vector has a non-trivial constructor.
But this really seems like there's a more normal way to do whatever it is you want to do.
I am trying to write a yacc parser and was trying to debug the issue where the parser run for a long time but the output stop after a certain point. Beside this I don't know what else I should do. Below is my code. Would you please help
Code:%{
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "defs.h"
#include "Geom.h"
#include "dbLayer.h"
#include "Term.h"
#include "Cell.h"
#include "dbNet.h"
#define YYMAXDEPTH 10000
#define YYDEBUG 1
int yylex(void);
void yyerror(char *);
extern int linecount;
extern int yylex();
extern int yyparse();
extern FILE *yyin;
extern FILE* yyout;
static std::map<char*,dbNet*>NET_HASH;
//static std::map<char*,dbNet*>::iterator NET_ITER;
static std::map<char*,dbMacro*>MACRO_HASH;
//static std::map<char*,dbMacro*>::iterator MACRO_ITER;
%}
%union {
int ival;
float fval;
char* sval;
int pindir;
std::vector<char*>* charportlist;
};
I have no idea, and don't want to think about, whether a pointer to a vector is allowed in a union. Yacc and I are not really on speaking terms, so I can't provide debugging help; but I don't really like the looks of that union. What (if anything) is it supposed to represent?
Yeah I think I have to remove it and define it somewhere else. I am new to this yacc thing so I might do something stupid here. Anyway, thanks you guys for directing to the right direction.:)