Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!oberon!cit-vax!elroy!mahendo!jplgodo!wlbr!scgvaxd!ashtate!dbase!drc
From: drc@dbase.UUCP (Dennis Cohen)
Newsgroups: comp.sys.mac.programmer
Subject: Re: I thought I knew C, but...
Message-ID: <366@dbase.UUCP>
Date: 1 Jun 88 14:17:08 GMT
References: <341STORKEL@RICE>
Organization: Ashton Tate Development Center Glendale Cal.
Lines: 30

In article <341STORKEL@RICE>, STORKEL@RICE.BITNET (Scott Storkel) writes:
> Okay, I give up. Could somebody please explain the following problem to me?
> I tried to compile the following piece of code using  MPW C:
> 
> void convertfile()
> {
>      SFReply        myreply;
>      Point          where;
>      SFTypeList     mylist;
> 
>      where.v=40;
>      where.h=40;
>      mylist[0]="WORD";
>      SFGetFile(&where, "File to convert?",nil,1,mylist,nil,&myreply);
> }
> 

As noted, it wanted single quotes around WORD rather than double quotes.  That
is because mylist[0] is a 4-byte quantity known as an OSType rather than a
string (in Pascal, Packed Array [0..3] of Char).  By putting single quotes
around WORD, the compiler treated it properly (:->) as a long, while with
double quotes, you had a 5-byte quantity (trailing null) which was aligned
improperly.  BTW:  This is a very common mistake among the C programmers I've
known who were new to the Mac.

Dennis Cohen
Ashton-Tate Macintosh Division
dBASE Mac Development Team
--------------------------
Disclaimer:  Opinions expressed above are _MINE_!