help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem initializing const members of position class


From: Akim Demaille
Subject: Re: Problem initializing const members of position class
Date: Thu, 06 Jan 2005 16:56:58 +0100
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux)

>>> "Moss," == Moss, Jeff <address@hidden> writes:

 > 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;

But there's a risk of having several times such definitions if there
are several parsers, that's precisely why it was done this way.  But
then we might have several location/position/stack files too.  This
auxiliary files issue is not settled down yet.


VC++ 6.0 is known to be quite non compliant :(  Can't you use any
standard compiler?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]