bug-bison
[Top][All Lists]
Advanced

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

Re: bison'd files don't compile under Microsoft VC++


From: Hans Aberg
Subject: Re: bison'd files don't compile under Microsoft VC++
Date: Wed, 13 Feb 2002 23:42:05 +0100

At 19:47 +0100 2002/02/13, Akim Demaille wrote:
>| One of the 'features' of the Microsoft environment is that size_t isn't in
>| the std:: namespace.
>| malloc and free didn't make it either.

Strange, I mean if you have the <cstddef> header. Are sure you compiler
ain't very old?

>| The versions of bison.simple in Bison 1.3.1 and Bison 1.3.3 won't work with
>| Microsoft.
>
>I was sure this would happen.  Sigh.
...
>Well, may I ask you what would happen had Bison output some real C++?
>Would you switch to that environment, or would you still use the C
>parsers compiled with a C++ compiler?
>
>I think we went too far in our attempt to please C++ compilers.
>Bison.simple is definitely meant for C.
>
>Opinions?  Paul?  I hope to be able to release Bison 1.50 with C++
>some time in the next two months, but...

It is not so difficult to fix:

In bison.simple, change to:
#ifndef YYSTD
# ifdef __cplusplus
#  define YYSTD(x) std::x
# else
#  define YYSTD(x) x
# endif
#endif

and to (writing in YYSTD in the C++ part):

#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
# define YYSIZE_T __SIZE_TYPE__
#endif
#if ! defined (YYSIZE_T) && defined (size_t)
# define YYSIZE_T size_t
#endif
#if ! defined (YYSIZE_T)
# ifdef __cplusplus
#  include <cstddef> /* INFRINGES ON USER NAME SPACE */
#  define YYSIZE_T YYSTD(size_t)
# else
#  ifdef __STDC__
#   include <stddef.h> /* INFRINGES ON USER NAME SPACE */
#   define YYSIZE_T size_t
#  endif
# endif
#endif
#if ! defined (YYSIZE_T)
# define YYSIZE_T unsigned int
#endif

Then those that insist on using obsolete and backwards compilers that don't
use the appropriate namespaces can put into their .y file:
#define YYSTD(x) x

-- This is of course the idea of using YYSTD everywhere instead of defining
the names explicitly. (If one wants, one can put it in also in the palces
which are only compiled using C, but I really do not know any use of that,
so I didn't do that above.)

  Hans Aberg





reply via email to

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