🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2400

Re: void* type

#2400
From: Claus Hirth
Date: Wed, 27 Mar 1996 00:57
32 lines
1152 bytes
Kurt Watzka (watzka@stat.uni-muenchen.de) wrote:

: yang@math.umass.edu (Huayong Yang) writes:

: >void Swap(void** p1, void** p2)

: It is not allowed to dereference a void *, not is it necessary in
: this example.

I agree. But you forgot to give an answer to Huayong.
Please enlighten us with *your* solution to this problem.

The best I could directly think of is :

void swap(void ** x, void ** y)
{
	char * tmp;

	tmp = *( (char**)x );
	*( (char**)x ) = *( (char**)y );
	*( (char**)y ) = tmp;
}

You would call it for 
	SomeType * x, * y 
sth like
	swap((void**)&x,(void**)&y);
to avoid "incompatible pointer type"-warnings.

Best regards

	Claus
Technical Details
Message-ID: <4ja3qf$p9b@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4iepre$ag7@solutions.solon.com> <4ii34g$nlp@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: Claus Hirth <hirth@wand.franken.de>
Newsgroups: comp.lang.c.moderated
Subject: Re: void* type
Date: 26 Mar 1996 18:57:51 -0600
Organization: private site
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4ja3qf$p9b@solutions.solon.com>
References: <4iepre$ag7@solutions.solon.com> <4ii34g$nlp@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com
X-Newsreader: TIN [version 1.2 PL2]