help-flex
[Top][All Lists]
Advanced

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

Re: Flex 2.5.23 beta and C++


From: W. L. Estes
Subject: Re: Flex 2.5.23 beta and C++
Date: Tue, 22 Oct 2002 09:29:15 -0400
User-agent: Mutt/1.3.28i

On Tuesday, 22 October 2002,15:11 +0200, Hans Aberg wrote:

> At 13:43 -0400 2002/10/21, W. L. Estes wrote:
> >flex beta version 2.5.23 has been released at:
> >
> >ftp://ftp.uncg.edu/people/wlestes/
> 
> I get errors when trying to compile the Flex generated lexer under C++:

Um, I thought that functions like exit() and such worked under c++?

> - Under C++, standard C construct end up in namespace "std". One can either
> throw in a "using namespace C++", which is not so good because the
> advantage of C++ namespaces is then lost, or write out the "std::" prefix
> explicitly.
> 
> The latter is not so difficult if one adds a macro:
> #ifdef __cplusplus
> # define YY_STD(x)  std::x
> #else
> # define YY_STD(x)
> #endif
> 
> Then write out:
>     YY_STD(size_t)
>     YY_STD(exit)
>     YY_STD(malloc)
>     YY_STD(realloc)
>     YY_STD(free)

This is going to make flex code look ugly. As such, I'm against it. If
c++ is really that broken, then I'm very un-interested in supporting
it. simple calls to exit, and types such as size_t have worked in c++
for years, afaik. Why should it suddenly break?

> - As for the macro FLEX_NEED_INTEGRAL_TYPE_DEFINITIONS, have you tried to
> set it relative C version? -- I figure that these integral types are part
> of C99.

hardly anybody seems to have C99 so it wasn't worth the
trouble. Hardly anybody seems to have inttypes.h either so it wasn't
worth trying to include that file. right now, it's sys/types.h or you
define a constant with an ugly name.

> There is a macro defined in C94, __STD_VERSION__, which expands to 199409L
> in that version. And current standard C++ does not have those integral
> types.

Then compiling your c++ scanner with
FLEX_NEED_INTEGRAL_TYPE_DEFINITIONS should still work.

Well, the c++ api is going to get a major re-write one of these
days. It looks like c++ and C are going in divergent directions which
is a shame.

--Will




reply via email to

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