Re: glr2.cc compile errors under Windows

Akim Demaille <[email protected]> Sun, 21 Nov 2021 10:25:18 +0100
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
Jot,

> Le 20 nov. 2021 à 15:57, Jot Dot <[email protected]> a écrit :
> 
> Hi Akim,
> 
>> Could you please attach that parser.h file?  Or a link to it?  Or at least the
>> relevant excerpts, so that we can have a look at what confuses it.
>> 
>> Did you make sure it compiled in C++11?  Actually I would even make sure to be
>> in C++14 mode.
> 
> 1>D:\data\c\runtime\parser.h(246,1): error C2535: 'yy::parser::basic_symbol<Base> &yy::parser::basic_symbol<Base>::operator =(const yy::parser::basic_symbol<Base> &)': member function already defined or declared
> 1>D:\data\c\runtime\parser.h(203): message : see declaration of 'yy::parser::basic_symbol<Base>::operator ='
> 1>D:\data\c\runtime\parser.h(248): message : see reference to class template instantiation 'yy::parser::basic_symbol<Base>' being compiled

   202	      /// Copy assignment.
   203	      basic_symbol& operator= (const basic_symbol& that)
   204	      {
   205	        Base::operator= (that);
   206	        value = that.value;
   207	        return *this;
   208	      }

   243	    private:
   244	#if YY_CPLUSPLUS < 201103L
   245	      /// Assignment operator.
   246	      basic_symbol& operator= (const basic_symbol& that);
   247	#endif

So your compiler is right, we do have a duplicate definition.  However it is not supposed to see the second one, because it should not be visible in C++17.

    53	#if defined __cplusplus
    54	# define YY_CPLUSPLUS __cplusplus
    55	#else
    56	# define YY_CPLUSPLUS 199711L
    57	#endif

Please check why your compiler does not define __cplusplus.  Compliant compilers must define it properly so that we can know what version of C++17 we're in.  See https://en.cppreference.com/w/cpp/preprocessor/replace#Predefined_macros.

> 1>D:\data\c\runtime\parser.h(246,1): error C2535: 'yy::parser::basic_symbol<yy::parser::by_kind> &yy::parser::basic_symbol<yy::parser::by_kind>::operator =(const yy::parser::basic_symbol<yy::parser::by_kind> &)': member function already defined or declared
> 1>D:\data\c\runtime\parser.h(203): message : see declaration of 'yy::parser::basic_symbol<yy::parser::by_kind>::operator ='
> 1>D:\data\c\runtime\parser.h(295): message : see reference to class template instantiation 'yy::parser::basic_symbol<yy::parser::by_kind>' being compiled
> 1>D:\data\c\runtime\parser.y(7,15): error C2065: 'YYSTYPE': undeclared identifier

Don't use YYSTYPE.  Use parser::value_type.

Cheers!