Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!uunet!mcsun!hp4nl!dnlunx!stan From: stan@dnlunx.pttrnl.nl (Stan van de Burgt) Newsgroups: comp.sys.mac.programmer Subject: Re: Bison / Yacc and Think C: missing bcopy and alloca (Summary) Message-ID: <9955@dnlunx.pttrnl.nl> Date: 28 May 91 12:22:05 GMT Article-I.D.: dnlunx.9955 References: <9740@dnlunx.pttrnl.nl> Organization: PTT Research Neher Laboratorium Lines: 50 I wrote: >I am trying to port a yacc/c program to the mac. Doing this I ran into >the following: After creating the parser from the yacc file with a PD >yacc (bison) on the mac, Think C seems to be missing the following >functions or macro's: > undefined: alloca (lotosy.tab.c) > undefined: bcopy (lotosy.tab.c) >Is there someone who could give me the obvious answer? Here's a summary of the answers I got upto now: 1) "The sources of bcopy and alloca are in the bison package. Just add the source to the project." Right. I was only using the application and the skeletons. 2) "#define bcopy(src,dest,len) memcpy(dest,src,len) #define alloca malloc to make for something that works but has a memory leak." also works. 3) Found this myself after looking carefully at the C program bison generates: The bcopy and alloca functions are only called in an emergency, only in case of a parser stack overflow. In this case a message is printed and the stack is temporally extended with alloca. If the programmer provides his own macro the piece of code with the two function calls is skipped. So I added: #define yyoverflow(msg,b,c,d,e,f,g,h) { yyerror(msg); exit(2); } This seems to work fine! I like to thank: ruurd@ooc.uva.nl pas@kepler.unh.edu d88-jwa@nada.kth.se neeri@iis.ethz.CH rcbalc@urc.tue.nl for their help. Stan -- S.P. van de Burgt PTT Research, Neher Labs PO Box 421, Leidschendam E-mail: SP_vdBurgt@pttrnl.nl the Netherlands