Path: utzoo!attcan!uunet!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!kth.se!cyklop.nada.kth.se!news From: d88-jwa@dront.nada.kth.se (Jon W{tte) Newsgroups: comp.sys.mac.programmer Subject: Re: ThinkC prototypes and Str255 args Message-ID: <1990Sep15.214039.25560@nada.kth.se> Date: 15 Sep 90 21:40:39 GMT References: <1990Sep15.154434.17307@midway.uchicago.edu> <4449@sage.cc.purdue.edu> Organization: Royal Institute of Technology, Stockholm, Sweden Lines: 35 In article <4449@sage.cc.purdue.edu> ar4@sage.cc.purdue.edu (Piper Keairnes) writes: >There is one problem... C passes arguments by value. So, when you make a >call to some procedure that expects a Str255, it is expecting the entire >string array. When you make a call such as the one above, C is simply Oh, no, it doesn't ! Arrays are passed by reference in C, that's why { char * moof; char foom[]; moof = foom; function(moof); } is equivalent with ... function(foom); If you cast to void *, things will run smoothly... >All that this function does is takes your string literal and stores it in a >variable of type Str255 then calls the intended function with that variable. >You can do this yourself in your code, or make a small function like >above to handle the interface and keep you code a little cleaner. This is >what we get for programming in C on a machine that was written in Pascal! Check that again after you've got some sleep. A single cast will do ! h+ Jon W{tte, Stockholm, Sweden, h+@nada.kth.se