[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bizarre ifdef logic in generated parser
From: |
Tim Van Holder |
Subject: |
Re: bizarre ifdef logic in generated parser |
Date: |
27 Jan 2003 14:03:13 +0100 |
On Mon, 2003-01-27 at 11:33, Aharon Robbins wrote:
> Greetings.
>
> I note the following:
>
> # if YYSTACK_USE_ALLOCA
> # define YYSTACK_ALLOC alloca
> # else
> ---> # ifndef YYSTACK_USE_ALLOCA
> # if defined (alloca) || defined (_ALLOCA_H)
> # define YYSTACK_ALLOC alloca
> # else
> # ifdef __GNUC__
> # define YYSTACK_ALLOC __builtin_alloca
> # endif
> # endif
> ---> # endif
> # endif
>
> It seems that the marked test can be omitted, given that it's already
> in the else part of `if YYSTACK_USE_ALLOCA', we know it's not
> defined.
No we don't - there are 3 distinct situations:
1. #define YYSTACK_USE_ALLOCA 0
2. #define YYSTACK_USE_ALLOCA 1
3. /* no definition for YYSTACK_USE_ALLOCA */
#if YYSTACK_USE_ALLOCA
case 2
#else
# ifdef YYSTACK_USE_ALLOCA
case 1
# else
case 3
# endif
#endif
In this case the snippet of code means that if alloca has not been
explicitly enabled or disabled, that alloca will be used if possible
(i.e. when alloca.h is available, or we're being compiled with gcc).
--
Tim Van Holder <address@hidden>