Casting the return value of malloc() ?

I

Ian Collins

Mark said:
You might want to work on your english - the above doesn't entirely make
sense. Remove the word "either" and it does.
English should be capitalised. The second "you" should also go.
huh? When you're developing road-safety harnesses for people carriers,
you don't test them out on APVs and Big Dippers.
So how do you test the device drivers in that code before you have the
hardware? How do you simulate the behaviour of the system without
trashing a large number of people carriers?
So just to be clear, you're stating that you *used* to have good reason
to compile C as C++, but not any more?
I said "We *also* compiled". Our reason was much the same as K&R's, our
C compiler didn't check prototypes correctly. Running that dogs
breakfast of a code base through the C++ compiler flushed out a lot of
bugs. The same would not have been true for well written code!

The code in question had been written by a novice who had just
discovered enums. He used them as function parameters without checking
them for valid values. He then passed inappropriate integer values to
these functions. Even today's C compilers would pass this code, but C++
compilers will not. The c++ compiler made a good "enum lint".
 
C

CBFalconer

Mark said:
You might want to work on your english - the above doesn't
entirely make sense. Remove the word "either" and it does.

In other words you want him to clearly write:

"Well it's pretty clear you you don't understand the
concept of a simulation."

:)

BTW, English is always capitalized.
 
D

David Thompson

Before C was standardised, void wasn't part of the language and malloc
returned char*

FAQ 7.7, at the usual places and http://c-faq.com/

And even after 1989, and 1990, conforming compilers weren't instantly
available for, and installed on, all machines. It is quite possible
the system your (Roc's) course/school was using did still require
casting malloc. OTOH it is possible that the professor had just
learned the old way and wasn't (yet?) aware it had changed.

It was a fairly common practice for quite a few years after 1990 to
code the casts, even if working on a conforming system that didn't
need them, so you were ready to (back)port to an older system . It is
also conceivable that the professor wanted to teach you to do that,
but if so he apparently didn't explain it adequately.

- formerly david.thompson1 || achar(64) || worldnet.att.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top