[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Problem initializing const members of position class
From: |
Moss, Jeff |
Subject: |
Problem initializing const members of position class |
Date: |
Thu, 6 Jan 2005 10:33:14 -0500 |
I've been trying to implement a very simple grammar using Bison 2.0
and Microsoft Visual C++ 6.0, and I have run into an issue that you may
want to know about.
There is a problem if the position.hh file gets included in more than one
C++ file. And it has to be included in the lexer because a reference to
yylloc gets passed into yylex() to get the location information.
So what happens is that the initialization code for "initial_column" and
"initial_line" that's in the header file gets executed twice, which causes
a multiple initialization error.
The only way I could fix this was to remove the initialization code from
position.hh and add it to the C++ file containing the parser class.
/* Initialize const members of the position class */
const unsigned int yy::position::initial_column = 0;
const unsigned int yy::position::initial_line = 1;
Regards
Jeff
- Problem initializing const members of position class,
Moss, Jeff <=