Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-lcc!well!ewhac From: ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) Newsgroups: comp.sys.amiga Subject: Re: Lock and FileLock Message-ID: <2965@well.UUCP> Date: Thu, 30-Apr-87 04:45:08 EDT Article-I.D.: well.2965 Posted: Thu Apr 30 04:45:08 1987 Date-Received: Sat, 2-May-87 07:46:11 EDT References: <6640@allegra.UUCP> Reply-To: ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 67 Summary: The Full and Compleat Story (I hope) In article <6640@allegra.UUCP> dsf@allegra.UUCP (David Fox) writes: >Furthermore, when I try to look at the >field fd_Task of a lock, my system crashes. Can anyone explain this to >me? > >David Fox >allegra!dsf > >P.S. By look at, I mean that if I execute the statement >task = lock->fl_Task, my system crashes. Phew. Here we go again. To all self-proclaimed Amiga Gurus reading this, please let lesser-experienced Amiga programmers that you know in on this information. (In fact, someone could probably make some serious $$$ writing a book about all the "common" knowledge that isn't in the manuals.) Note: People who have heard this a million times might want to hit 'n' now. Rule #1: The DOS sucks. Rule #2: The DOS was not written in C, it was written in a language called BCPL (an acronym meaning, "British Compiler Programmers are Lousy" (q.v. Rule #1)). Because the languages are different, C's idea of a pointer is different from BCPL's idea of a pointer. Rule #3: Memory as we know it is addressed in byte-sized increments. BCPL, however, thinks memory is addressed in longword-sized increments. Therefore, a memory address in a BCPL pointer must be multiplied by the size of a longword in bytes (i.e. four) to get a real memory address. Typically, this is done in C as follows: char *c_pointer; c_pointer = (char *) ((long) bcpl_pointer << 2); The various type casts may or may not be necessary, but it makes the compiler shut up. Rule #4: All AmigaDOS functions that claim to return a pointer in fact return a BCPL pointer, commonly called a BPTR (meaning, "Braindamaged PoinTeR"). Rule #5: Only those functions covered in the AmigaDOS Developer's Manual are AmigaDOS functions. All other functions in the ROM Kernel are normal and well-behaved (e.g. GetMsg() does NOT return a BPTR (thank God)). David: This was not meant to be insulting. It's just that this has been covered many times before, and things of this nature really ought to be in the manuals in 36-point bold type. As it is, people have to ask here. Sigh. Hope this helps. Spread this information far and wide; you will help many novices this way. P.S: Sprinkle :-)'s where appropriate. _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ ________ ___ Leo L. Schwab \ /___--__ The Guy in The Cape ___ ___ /\ ---##\ ihnp4!ptsfa!well!ewhac / X \_____ | __ _---)) ..or.. / /_\-- -----+==____\ // \ _ well ---\ ___ ( o---+------------------O/ \/ \ dual ----> !unicom!ewhac \ / ___ \_ (`o ) hplabs -/ ("AE-wack") ____ \___/ \_/ Recumbent Bikes: "Work FOR? I don't work FOR The _O_n_l_y Way To Fly! anybody! I'm just having fun."