#: 16319 S3/Languages
27-Aug-92 16:32:58
Sb: #16300-#Your July article
Fm: Mark Griffith 76070,41
To: Bob van der Poel 76510,2203 (X)
Bob,
Well, I suppose I could have been more mellow in my initial message, so I'll
apologize for that. However, I think you miss my point. I'm not saying that
void *malloc() is wrong per se, just that is is misleading to those people
trying to learn "C". In your self-assumed role as a teacher of the subject, it
is your responsibility to be as clear as possible on the subject, even if it
means sticking to the more arcane OSK conventions than the newer ANSI stuff. A
new "C" programmer might easily get confused when they see a function that
obviously returns something declared as a type void, no matter how "politically
correct" it may be.
Also, if you try to assign the return value of malloc() to an unsigned char
type, the compiler SHOULD complain because the two datat types are not the
same. Declaring malloc() as a type void doesn't fix the problem, it meerly
masks it. If you take a piece of code that has malloc return a char * type and
compare it to the same code but with malloc() returning a void * pointer, that
assembler for both of them is exactly the same. That leads me to believe that
the compiler is not doing anything different, it just ignores any errors.
Of course, some more research should be done to confirm or deny this, but my
basic point is that same. Again, I'll state that just because it appears in
headers for other compilers, does not make it a trueism for all compilers.
Mark
There is 1 Reply.
|