Re: Need some help with dereferencing structures and such

From: Andrew Falanga (andy_at_spam.me.not)
Date: 02/02/04


Date: Mon, 2 Feb 2004 11:55:21 -0700

On Sat, 31 Jan 2004 17:59:58 GMT
Leor Zolman <leor@bdsoft.com> wrote:

> On Sat, 31 Jan 2004 02:47:56 -0700, Andrew Falanga <andy@spam.me.not>
> wrote:
>
> There isn't much the language(s) let you do with a void pointer,
> because it wouldn't be type-safe. Basically, you can copy them around
> and that's about it. Since p is a pointer to "nothing in particular",
> how could the compiler know how to generate code for that statement?
>
> I don't get what you're hoping to gain by having accessData take a
> void pointer in the first place. What's the parameter supposed to
> represent? What are you doing before the call to set up for it? Are
> you creating an initial, empty node and passing that in as that first
> arg? In that case, why not just make the parameter a "product *" (or
> whatever you end up calling it) to reflect what it really is?
>
> If you're thinking that accessData might be usable for many different
> kinds of linked list nodes in some "generic" sort of way, there are
> way to get there, but passing a void * isn't in my mind one them. Tell
> us what your goals are here for this function...
> -leor

Ok, that makes sense. I didn't have a lot of time to putz with it so I basically left it on Saturday. I was actually thinking that this was my problem, trying to use a void type as a struct and the compiler not knowing exactly what was going on. I hadn't actually gotten to the point of trying to cast them as Thomas mentioned.

I was trying to write this as genericly as possible, but I can see now that this really can't be done because of the application I'm writing. Even if I do use pointers to void, I have to cast them to the structure "type" anyway which really doesn't gain anything. I might as well pass a struct pointer.

Thanks much for the help. Oh, in case you were wondering, I was trying to write this function (as well as others, I just haven't gotten to them yet) as linked libraries.

Andy

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----