Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!njin!princeton!phoenix!mbkennel From: mbkennel@phoenix.Princeton.EDU (Matthew B. Kennel) Newsgroups: comp.sys.mac.programmer Subject: Re: Question about Bison Message-ID: <3889@phoenix.Princeton.EDU> Date: 8 Oct 88 21:28:03 GMT References: <8246@cit-vax.Caltech.Edu> Reply-To: mbkennel@phoenix.Princeton.EDU (Matthew B. Kennel) Organization: Princeton University, NJ Lines: 41 In article <8246@cit-vax.Caltech.Edu> janin@tybalt.caltech.edu (Adam L. Janin) writes: >I just installed Bison on a Mac II and I'm having a problem when linking. >Using bison.simple, I get a link error (missing functions alloca and bcopy). >When I use bison.hairy (using the %semantic_parser command), I get other link >errors (several missing functions). I assume I should simply replace >alloca with NewPtr and bcopy with MemCopy. Is this correct? > Thanks, > Adam Janin > janin@tybalt.caltech.edu or janin@csvax.caltech.edu Oh, no, it's the "alloca" argument all over again. I believe that alloca is a function to allocate local storage. The difference between it and malloc is that all storage allocated by alloca will get disposed _automatically_ whenever the function that called alloca returns. The problem comes in on the "automatically" part. I believe that in general implementing "alloca" can be quite difficult on some architectures, and often needs some pretty close consideration on the part of the compiler. Some people have argued that just having the ability to do an "alloca" implemented can seriously slow down function calls, especially on some RISC machines. Thus, some people have argued that "alloca" should be abolished from use, replaced, by explicit allocate/free calls. Unfortunately, Richard Stallman is pretty dogmatically in favor of the other side, and so it looks like "alloca" will continue to be used in many FSF programs (of which Bison and Emacs are examples). The bottom line for your specific problem is: You might either have to write "alloca" (Which might be quite difficult). Or, you have to modify Bison to use malloc and the appropriate free call explicitly. In this respect, the UNIX call "malloc" is analogous to the MacOS call "NewPtr." If you replace all calls to "alloca" to "malloc" or "NewPtr", it will still work, but you will get serious memory fragmentation over time. I think that "bcopy" does just about the same thing as "BlockMove". Matt Kennel mbkennel@phoenix.princeton.edu