Subject: | |
From: | |
Reply To: | |
Date: | Wed, 28 Oct 1998 10:59:05 -0700 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
John Zoltak writes:
>Here is a compilable code snippet in HP C/iX. I always get the Warning
>604. I cannot think of a cast to eliminate it. According to the book;
>
>In an assignment expression, if both the left hand and right hand side
>expressions are pointers, then the right hand side expression must
>either be the same type as the left side expression, or a pointer to
>void.
>
>Correct the expression (possibly by inserting a cast).
>
> 3 0 short (*pASCII)(short word, short base, char *string);
> 4 0
> 5 0 void *load()
> 6 0 {
>...
> 10 1 }
> 11 0
> 12 0 void main()
> 13 0 {
> 14 1 pASCII = load();
> 15 1 }
>cc: "CTEST01.PUB.LIB", line 14: warning 604: Pointers are not
>assignment-compatible.
The book has the rule misstated. The LHS, not the RHS of the expression
can be a pointer to void. You can't assign a pointer to void to any other
kind of pointer without an explicit cast, but you can assign any pointer
type to a pointer to void. (Think about void * parameters, for example.)
-- Bruce
--------------------------------------------------------------------------
Bruce Toback Tel: (602) 996-8601| My candle burns at both ends;
OPT, Inc. (800) 858-4507| It will not last the night;
11801 N. Tatum Blvd. Ste. 142 | But ah, my foes, and oh, my friends -
Phoenix AZ 85028 | It gives a lovely light.
btoback AT optc.com | -- Edna St. Vincent Millay
Mail sent to [log in to unmask] will be inspected for a
fee of US$250. Mailing to said address constitutes agreement to
pay, including collection costs.
|
|
|