Non-Portable pointer assignment?

Roy M. Silvernail roy%cybrspc at cs.umn.edu
Tue Jun 4 14:02:34 AEST 1991


darcy at druid.uucp (D'Arcy J.M. Cain) writes:

> That's because the compiler sees you trying to assign an int to a pointer
> to character.  To my mind it is being too polite.  It should say "Assignment
> of pointer from integer lacks a cast" as well as telling you that strchr
> is used without being declared.

To tell the truth, I'd rather it have been a fatal compile error.  That
would have been more helpful to me that a warning and Doing The Right
Thing.

> Note that with Turbo C, like many other
> ANSI compilers, will let you turn on lots of warnings and if you had done
> so it would have caught this. (*)

And so I shall, believe me.  (that's what I get for hacking way past my
bedtime :-)

> BTW, TFTM (The fine Turbo manual) shows you which header file(s) you
> should include if you call a function.  If you include the ones it
> indicates you will save yourself lots of grief one day.

Agreed, as does the help function in TC IDE, and the THELP TSR.
Unfortunately, I got one of those occasional recto-cranial displacements
and neglected to look at them.

> (*) My favorite CFLAGS with GNU C:
>     CFLAGS = -O -Wall -ansi -pedantic
> and I still expect my programs to compile with no errors or warnings.

I'll see if I can get Turbo to act similarly, although I've already had
dos.h fail with the 'ANSI keywords only' directive enabled.  I suppose I
should just chuck DOS for an operating system.  (it'd be easier to get
GCC, too)

Thanks for the help!
--
Roy M. Silvernail --  roy%cybrspc at cs.umn.edu - OR-  cybrspc!roy at cs.umn.edu
  perl -e '$x = 1/20; print "Just my \$$x! (adjusted for inflation)\n"'
        "What do you mean, you've never been to Alpha Centauri?"
                                               -- Prostetnic Vogon Jeltz



More information about the Comp.lang.c mailing list