Mail Archives: djgpp/1998/08/07/18:31:45
In article <Pine DOT SOL DOT 3 DOT 96 DOT 980805225348 DOT 734A-100000 AT sol DOT sun DOT csd DOT unb DOT ca>,
Endlisnis <s257m AT unb DOT ca> writes:
>On Wed, 29 Jul 1998, Inquisitor Nikodemus wrote:
>->During writing a function I noticed that operations - such as addition
>->or substraction - on pointers of different types than char didn't
>->behave as I expected them to. Eg. adding 2 to the the pointer :
>-> short *pointer_to_short ;
>->resulted in 4 byte offset,not 2 byte. Same for ints etc.
>->So the question is : is it really a fact,that gcc's pointer math
>->depends on type rather than raw bytes ?
> That's how it is in all ANSI C++ compilers.
Even pre-ANSI. I read the original Kernighan & Ritchie book, and they said
that that is just how the C language works. It's a feature of the language.
--Ed (Myknees)
- Raw text -