strncpy

Kannan Konath konath at sj.ate.slb.com
Thu Jan 4 02:07:11 AEST 1990


I had asked this question,  around two weeks ago.  I received a good
number of answers by email.  Thanks for the replies. I had also
promised to post a summary.

Well here goes....

The question was:

Why does the C compiler not come up with an error when a function, say
foo,  of zero arguments gets called in the following manner.

	foo;  /* the parentheses are missing */

Answer:
I did not know it at that time, but the above statement "foo;" just
generates the address of the function foo.  Since expressions are
allowed to stand all by themselves in C, this passes and rightly so.
In fact this statement in particular has a null effect,  though in my
opinion expressions without any side effect should generate warnings
but then I suppose C's philosophy lies behind this lack of warnings
even in cases like this.

To detect these sort of errors, lint can be used.  In particular if
you are working on a BSD Unix system you need to use the "-h" flag
which points this error out.



More information about the Comp.lang.c mailing list