bug-make
[Top][All Lists]
Advanced

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

[bug #27609] Stupid inference rule for yacc files can clobber C sources!


From: Kaz Kylheku
Subject: [bug #27609] Stupid inference rule for yacc files can clobber C sources!
Date: Mon, 05 Oct 2009 20:12:24 +0000
User-agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)

Follow-up Comment #2, bug #27609 (project make):

If I have two different yacc files that generate different parsers in the
same directory, then I'm going to be aware of that situation and resolve it.
If I don't resolve it, then they will both clobber y.tab.c, which is my fault.
I'm bitten by my own folly, and not by some hidden rule that destroys source
code.

That the yacc program clobbers y.tab.c is not the result of some secret rule
which only emerges when you've created an important file (not by means of
yacc) and named it y.tab.c! Everyone knows that yacc makes a y.tab.c file. 
Not everyone knows that make will clobber your foo.c, because a foo.y exists.

There are going to be other issues anyway. If I have two parsers that go into
the same link, there will be clashes on all the YY stuff. It's not enough to
just rename the files.

If I don't like the name y.tab.c, I can easily write a rule like this:

 myparser.c: myparser.y
    $(YACC) $(YFLAGS) -o $@ $<

If I want that to be an implicit rule for general .y -> .c conversion, I can
do it like this:

 %.c: %.y
    $(YACC) $(YFLAGS) -o $@ $<

Now I have a rule which clobbers .c files. I wrote it; it's spelled out in my
Makefile. If that overwrites a non-generated .c file, it serves me right!


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?27609>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/





reply via email to

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