🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9642

Re: Must casting destroy lvalueness?

#9642
From: stephen
Date: Thu, 23 Oct 1986 13:19
21 lines
1173 bytes
I generally use or define caddr_t as the type of a generic pointer, and then
use macros to perform the indicated operations, i.e.:

caddr_t generic_pointer;

#define DATA( p, type ) (*((type *)(p)))
#define SUCC( p, type ) ((p) += sizeof(type))
#define PRED( p, type ) ((p) -= sizeof(type))

a = DATA(p,int);
SUCC(a, int);
b = DATA(p,double);
SUCC(p, double);

In the case of a compiler where the cast in DATA is invalid, an 
alternate formulation can be made.


Stephen Watkins                    UUCP: ihnp4!datacube!stephen
Datacube Inc.; 4 Dearborn Rd.; Peabody, Ma. 01960; 617-535-6644
Technical Details
Message-ID: <7800017@datacube>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!rutgers!pyrnj!mirror!datacube!stephen
References: <4763@brl-smoke.ARPA>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!rutgers!pyrnj!mirror!datacube!stephen
From: stephen@datacube.UUCP
Newsgroups: net.lang.c
Subject: Re: Must casting destroy lvalueness?
Message-ID: <7800017@datacube>
Date: Thu, 23-Oct-86 09:19:00 EDT
Article-I.D.: datacube.7800017
Posted: Thu Oct 23 09:19:00 1986
Date-Received: Fri, 24-Oct-86 17:31:42 EDT
References: <4763@brl-smoke.ARPA>
Lines: 21
Nf-ID: #R:brl-smoke.ARPA:-476300:datacube:7800017:000:592
Nf-From: datacube.UUCP!stephen    Oct 23 09:19:00 1986