Subj : Re: How can I get rid of #define in my generated C code ...? To : comp.programming From : David Tiktin Date : Tue Oct 11 2005 02:50 pm On 09 Oct 2005, "Bahram" wrote: > I am using lex and yacc for a project I am working on, wondering > if there is any switch I can specify ANYWHERE, including the C > compiler, that would take the .c files that these utilities > generate, and get rid of all the #defines in the generated code. > (when I say get rid of, I don't mean to simply delete, I mean to > recognize: Oh yes, this is defined and here is what I want to do.) > > The y.tab.c and lex.yy.c files that these utilities produce are > infested with #define, a lot conditional, making them impossible > to read, and modify (e.g. yes, I need to make some changes to > them) Are you talking about #ifdef and #ifndef blocks littering the code? So you want the code with the correct constructs for your platform included but without the clauses that apply to other platforms? If so, your editor may have a feature to "collapse" the code based on the values of the #defines you specify. The one I use does this using a feature called "Selective Display." (If you don't define DEBUG, for example, all #ifdef DEBUG constructs disappear.) It also allows you to just copy the visible lines (those selectively displayed), which I think is what you want. Just copy and paste into a new file. Dave -- D.a.v.i.d T.i.k.t.i.n t.i.k.t.i.n [at] a.d.v.a.n.c.e.d.r.e.l.a.y [dot] c.o.m .