Xref: utzoo comp.sys.mac.hypercard:311 comp.sys.mac:11911 Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!pyramid!voder!apple!corwin From: corwin@apple.UUCP (Someone Else) Newsgroups: comp.sys.mac.hypercard,comp.sys.mac Subject: Re: HyperCard XFCNs in MPW C Message-ID: <7310@apple.UUCP> Date: 2 Feb 88 05:03:54 GMT References: <226STORKEL@RICE> <3105@watcgl.waterloo.edu> Reply-To: corwin@apple.UUCP (Someone Else) Organization: Apple Computer Inc., Cupertino, USA Lines: 59 In article <3105@watcgl.waterloo.edu> kdmoen@watcgl.waterloo.edu (Doug Moen) writes: >In article <226STORKEL@RICE> STORKEL@RICE.BITNET (Scott Storkel) writes: >>Help! I am trying to compile a Hypercard XFCN written in MPW C. The program >>compiles fine, then I try to link it using the following commands: >> >> link -sn Main=Bool -sn STDIO=Bool: >> -sn INTENV=Bool -rt XFCN=5: >> -m BOOL Boolean.c.o "{CLibraries}"CRuntime.o: >> "{CLibraries}"CInterface.o: >> "{CLibraries}"StdCLib.o: >> "{CLibraries}"CSANELib.o: >> -o HyperCommands just a side note... it is much easier to use the -sg option than a bunch of -sn's (it also works better!) >>When I do this, the compiler gives me the error "Data initialization code is >>not being called" and terminates. The output file contains the XFCN resources >>Bool=5, and also SADEV=6, SACONSOL=7, and CSANELIB=8. it eliminates multiple code resources such as in the above case. >You can't have global variables *or character string literals* in >an XFCN written in MPW C. >Some kludges for faking string literals: >* You can put them into STR# resources [code deleted] >Now you can replace character string literals like: > "foobar" >with: > char buf[256]; > ... > strlit(buf, 'foob','ar\0\0'); which is nice, as long as you are not using a MC68020... MPW C has a tendancy to misalign longwords... the MC68020 can deal with this... a MC68000 will crash. I learned the hard way... I have somewhere between 20 and 40 XCMDs that used something similar... care to guess how long it took me to rewrite all of them to use resources? For the record, as long as you are not going to be running your XCMD more than about 10,000 times before re-starting hypercard, you can use strings (as well as several other things) with LSC. (if anyone is interested, I have a code sample that will crash after ~10K executions) -cory -- #include UUCP: {sun,voder,nsc,mtxinu,dual}!apple!corwin CSNET: corwin@apple.com ARPA: corwin@apple.com