johnl@haddock.UUCP (02/07/84)
#R:sri-arpa:-1629500:haddock:16700009:000:1361 haddock!johnl Feb 6 16:53:00 1984 I also had the same problem of using yacc in more than one place in a program, but came up with a more overimplemented way of dealing with it. I wrote a program called "entry" which you would call as: $ entry aoutfile name1 name2 ... and it would fiddle bits in the aoutfile so that only the names you specified (and any undefined externals) were global. It basically retroactively declared everything else in that object file to be static. The idea was that you compiled one yacc piece, linked it with a few related modules, used "entry" on that so that only useful entries, not including yy*, were global and linked that with other stuff. You could do this recursively depending on how much symbol hiding you want to do. There were disadvantages, notably that the makefiles got ugly and the debuggers got confused in the presence of many symbols with the same name. What you really want in such a case (and what I've never seen implemented very well) is block structured link time symbol tables. At compile time if I have local variables named "i" in several routines, or even in several blocks in the same routine, it doesn't cause any trouble. It would be nice to have link time be as nice. As it is now, link time symbols are sort of like variables in early Fortran II programs -- either they're in common or they aren't. John Levine, ima!johnl
jab@uokvax.UUCP (02/08/84)
#R:sri-arpa:-1629500:uokvax:6100017:000:731 uokvax!jab Feb 5 21:10:00 1984 /***** uokvax:net.unix / sri-arpa!wales@ucla-locus / 7:28 am Feb 3, 1984 */ I recently had just such a situation on my hands, and I got around it by massaging the symbols in question so they would be unique -- as shown in the following sample excerpt from a makefile: blah.c blah.h: blah.y yacc -d blah.y mv y.tab.c blah.c mv y.tab.h blah.h blah.o: blah.c blah.h cc -S blah.c /lib/c2 blah.s | sed 's/_yy/_blah_yy/g' | as -o blah.o rm -f blah.s /* -------------- */ Rich has provided a workable way to do this, but be warned that if you don't have "flexnames" (arbitrary-length variable names) the names that this generates might be longer than eight characters and eventually cause you grief. Jeff Bowles Lisle, IL