Non-Portable pointer assignment?

Roy M. Silvernail roy%cybrspc at cs.umn.edu
Mon Jun 3 03:13:09 AEST 1991


(no, this isn't compiler-specific :-)

I use Turbo C, and sometimes get the warning "Non-portable pointer
assignment" when I do something like this:

foo(char *p) {
    char *q;

    q = strchr(p,'x');  /* this line gets complaints */
}

TFM says strchr() returns pointer to char, and the pointer I'm assigning
to is a pointer to char, so I'm in the dark.  On my platform, the code
works, but I try to write portably.

So, what's the proper (perhaps the ANSI) way to handle such an
assignment?  If Turbo is right, this snip of code will fail on other
machines or other compilers.
--
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