www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/05/12/09:30:23

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: Ian Miller <Ian AT shelob DOT plus DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: casting a pointer of a pointer
Message-ID: <MPG.17487bbf51597cee989680@usenet.plus.net>
References: <4PpD8.150757$v7 DOT 14044373 AT bin6 DOT nnrp DOT aus1 DOT giganews DOT com>
X-Newsreader: MicroPlanet Gravity v2.60
Lines: 29
Date: Sun, 12 May 2002 14:17:37 +0100
NNTP-Posting-Host: 212.56.100.56
X-Complaints-To: abuse AT plus DOT net DOT uk
X-Trace: stones 1021209358 212.56.100.56 (Sun, 12 May 2002 14:15:58 BST)
NNTP-Posting-Date: Sun, 12 May 2002 14:15:58 BST
Organization: Customer of PlusNet
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

In article <4PpD8.150757$v7 DOT 14044373 AT bin6 DOT nnrp DOT aus1 DOT giganews DOT com>, 
zfysz AT cybertrails DOT com says...
> unsigned short repcnt;
> unsigned char *li_s;
> 
> // get the WORD at li_s
> repcnt = (unsigned short) (unsigned short *) *li_s;
> 
> What I am trying to do is get the WORD at the BYTE PTR's
> location.

Surely you are casting (*li_s) which is an unsigned char
not a pointer.  Perhaps this would work better:

repcnt = *((unsigned short *) li_s);

Even that is not really safe because char pointers
don't have to satisfy the same alignment rules as
short pointers on all hardware.  I believe it does
work on x86 processors though.

> In VC6.x and QC2.5, the above compiles and
> works as expected

As you expect perhaps, but not as I do if it does
what you say.

HTH,
Ian

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019