takao21203
- Joined Apr 28, 2012
- 3,702
Bob, I find that interesting.
XC8 does take it into account. I tried it.
If x is a pointer, y*(y) will do a typecast, even when it will complain it is illegal.
When x is an integer, it does a multiplication.
x will contain the int value of y as address, I stepped through it, no multiplication taking place.
Maybe it is question of which standard the compiler supports. How it behaves must be defined.
Anyway, (unsigned char*)y looks better to me.
So you could also use (y*)y probably?
C sources can be very confusing when the way of doing these things is mixed.
XC8 does take it into account. I tried it.
If x is a pointer, y*(y) will do a typecast, even when it will complain it is illegal.
When x is an integer, it does a multiplication.
x will contain the int value of y as address, I stepped through it, no multiplication taking place.
Maybe it is question of which standard the compiler supports. How it behaves must be defined.
Anyway, (unsigned char*)y looks better to me.
So you could also use (y*)y probably?
C sources can be very confusing when the way of doing these things is mixed.