[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: #defines before C declarations?
From: |
Akim Demaille |
Subject: |
Re: #defines before C declarations? |
Date: |
02 Jul 2002 13:02:20 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter) |
| I'm using bison 1.28, and have found a bothersome issue... In my C
1.28 is dead since ages.
| declarations section, I do some includes of standard system files (e.g.
| unistd.h). After running bison, I see in my y.tab.c that bison has
| inserted a bunch of defines, defining the tokens, *before* my C
| declarations. In other words:
|
| %{
| #include <unistd.h>
| %}
| %token foo
| ...
|
| I then see this in y.tab.h:
|
| #define foo 257
| ...
| #define eof 371
| #include <unistd.h>
|
| My compile fails because some of the things bison #defines appear in
| unistd.h, which generates errors.
Change your names!
| Why doesn't bison insert its defines *after* my c-code, as does yacc?
| Note that the "eof" token isn't even something I define myself, so I
| can't just choose to use differently spelled tokens.
It just moves the problem, it solves nothing. Just don't name your
tokens `for', `while' or `abort' etc.