Path: utzoo!mnetor!uunet!husc6!bloom-beacon!mit-eddie!uw-beaver!cornell!rochester!udel!mmdf From: dsill@nswc-oas.arpa (Dave Sill) Newsgroups: comp.sys.amiga Subject: Re: 'void *' (was Re: malloc() prob. on 3.4a) Message-ID: <2184@louie.udel.EDU> Date: 20 Apr 88 17:36:56 GMT Sender: mmdf@udel.EDU Lines: 67 > It depends on your definition of 'right'. If you want to limit >yourself to obsolete versions of C, be my guest. I guess you're still missing my point. Using the K&R style doesn't limit you to any particular compilers at all; using `void *' limits you to "ANSI" compilers. >In my experience, to >write a [truly] portable C program (e.g. 32 bit int UNIX compiler to, say, >an IBM-PC C compiler) takes twice as long and as half as readable no >matter what you do. I totally agree. However, I'm not suggesting you make your Amiga programs truly portable. I'm suggesting you make them easier to port to other Amiga compilers. > It sounds like you aren't sure of your own code. I wonder what makes you say that. I'm sure of my code because I stick to the least common denominator, i.e. K&R C. Remember, we haven't even got an ANSI standard for C yet. How long do you think it will be before *everyone* has replaced his compiler with a real ANSI- compatible compiler? >The type on the right is obvious since it is >the same as the type on the left (in a pointer assignment); I don't need >to be told twice, and when I read my source 10 years from now it will >look as clear cut and clean and understandable as it did when I first >wrote it. Yes, the ANSI solution is cleaner. But the K&R solution is universal. I think it's premature to adopt the non-backward-compatible ANSI solution when there is a universal solution. I also think it's worth sacrificing a little code clarity for intercompiler portability. >KEEP IN MIND that this whole argument deals solely with >the declaration of functions that return different pointer types at >different times. It really started with: >>Leo has kind of set a convention of making a lot of intuition funcs() return >>void [*]-->void *OpenScreen(). Then in the code he has: s=OpenScreen(&sdef); (Which I still think is wrong.) What we're arguing about *is* functions that return different kinds of pointers. This is obviously becoming a religious issue. I think both sides have made their points, and I probably won't post another message on the topic. I'll conclude with a final summary of the two sides, as I see them. Pros Cons ----------------------------------------------------------------- K&R `char *' all compilers messy casts req'd including ANSI ----------------------------------------------------------------- ANSI `void *' ANSI compilers only no messy casts ----------------------------------------------------------------- As an aside, which Amiga C compilers *are* "ANSI"-compatible? Which aren't? ========= The opinions expressed above are mine. "There's always a place for least common denominators on the market." -- Bill Joy