Help me cast this!

paul pedersen pedersen at acf3.NYU.EDU
Sat May 7 02:59:02 AEST 1988


Walter Murray writes:
<The "possible pointer alignment problem" warning comes from the
<fact that malloc(3) is declared to return char*, even though we
<know that the alignment of its return pointer is such that it can
<be used for anything.  To get rid of that warning, try:
<
<   output = (struct outfile (*)[])(int)malloc(sizeof(struct outfile) * 3);
<
<Conversions of pointers to integral types and back are implementation-
<defined, but this should work if int on your machine is wide enough
<to hold a pointer.  If not, try long instead.


This is terrible, outrageous, and disgusting.  In order to get 'lint' to
shut up, this mechanism sacrifices portability!  The whole point of running
'lint' in the first place is to detect constructions that may work but are
not portable (I know there are other reasons for 'lint'-ing, but this is
the >primary< reason).

Better just to eat the lint complaints automatically with grep -v, as someone
else has already suggested.



More information about the Comp.lang.c mailing list