home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!rpi!ghost.dsi.unimi.it!univ-lyon1.fr!taloa.unice.fr!beust
- From: beust@aurora.unice.fr (Cedric Beust)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: AmigaDOS library functions and ANSI-C programming
- Date: 30 Dec 1992 10:42:49 +0100
- Organization: University of Nice Sophia-Antipolis, France
- Lines: 52
- Distribution: world
- Message-ID: <1hrqupINNipe@aurora.unice.fr>
- References: <1992Dec29.221144.26405@urbana.mcd.mot.com>
- NNTP-Posting-Host: aurora.unice.fr
-
-
- In article <1992Dec29.221144.26405@urbana.mcd.mot.com>,
- qbarnes@urbana.mcd.mot.com (Quentin Barnes) writes:
-
- >I ran across a widespread problem with the AmigaDOS specific
- >prototypes/libraries with writing ANSI-C code. AmigaDOS
- >functions which take pointers to objects when the objects
- >aren't modified are not marked as "const".
- >
- > [short example deleted]
- >
- >I don't care about hacks such as marking those errors ignored
- >or casting. The real problem is that the AmigaDOS library
- >function calls need their signatures cleaned up. This may be
- >an annoying problem with ANSI-C code, but it will prove fatal
- >with C++.
-
- Funny, I had the very same thought yesterday night! (no, I wasn't
- dreaming of Amiga programming, don't worry for my mental health :-)).
-
- I was reading the autodoc for AddHead which looks like
- AddHead(struct List *list, struct Node *node)
- and I was wondering if a copy of the node would be done and then
- pointed to in the list or if *my* node would be directly referenced.
-
- This is a major difference! The safest way in my mind is when
- the system takes care of allocating a new node, copying the one
- I pass and then referencing this one, leaving me free to to what
- I will with my node (I used this scheme in my generic database
- package which I described shortly in a previous post).
-
- The advantage of this method? Simple : you can use the same
- static node to create a list. For example :
-
- static struct Node *myNode;
-
- while (condition) {
- /* fill myNode with some value */
- AddHead(list, myNode);
- }
-
- There might be drawbacks of course but this is not my point (sorry,
- I digressed a little). Since this wasn't mentioned in the autodoc,
- I decided to go safe and allocate myself a new node at each call.
- The information might be in the RKM (I didn't check), but I really
- think this kind of detail should be mentioned, either in natural
- language, or by the use of the const keyword whenever possible.
-
- Just a few thoughts...
- --
- Cedric BEUST, beust@sa.inria.fr, Bull Research Koala proj, KoalaBus & xforum
- Pho:(33) 93.65.78.07(.66 Fax), INRIA, B.P.93 - 06902 Sophia Antipolis, FRANCE.
-