delorie.com/archives/browse.cgi | search |
From: | "Michel Gallant" <mgallant AT NOSPAM DOT grassroots DOT ns DOT ca> |
Newsgroups: | comp.os.msdos.djgpp |
References: | <35bf1ff4 DOT 1246159 AT news DOT icm DOT edu DOT pl> |
Subject: | Re: GCC and pointers : QUESTION |
Lines: | 26 |
Message-ID: | <B22A1.61$Qi3.325552@sapphire.mtt.net> |
Date: | Tue, 11 Aug 1998 20:44:17 GMT |
NNTP-Posting-Host: | 142.177.31.25 |
NNTP-Posting-Date: | Tue, 11 Aug 1998 17:44:17 ADT |
Organization: | MTT |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Inquisitor Nikodemus wrote in message <35bf1ff4 DOT 1246159 AT news DOT icm DOT edu DOT pl>... >Hey! > > >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 ? > > >/greetz >Nikki Sure looks like it. It appears to be performing referencing calculations based on variable type. Try it with long or short ints and see what happens. Michel Gallant
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |