Unix Programming - iov_set->iov_base+=cntcp; gives error

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > July 2004 > iov_set->iov_base+=cntcp; gives error





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author iov_set->iov_base+=cntcp; gives error
Wim Deprez

2004-07-28, 6:19 pm

Hello Group,

(still undusting and porting an old framework for reliable
multicasting)

the following (original) code processes an error (error C2036: 'void
*' : unknown size)

int cntcp;
struct iovec *iov_set ;

// ... (determine size of cntcp)
iov_set->iov_base+=cntcp;

well, I understand very well that this will turn into an error, but
what do I do then? What was the original programmers goal? I guess he
tries (tried) to read the information received from the multicastgroup
and uses the cntcp variable to browse the iov_set->iov_base buffer.
The problem is that you cannot add an int to a void *, I think you
should add it to the address like this:

iov_set->iov_base = cntcp + &iov_set->iov_base;

this code doesnot give an error. Might my thinking be ok? Or does the
fact that iov_set is already a pointer on itself complicate things?

Thanks in advance,

--wim
Lev Walkin

2004-07-28, 6:19 pm

Wim Deprez wrote:
> Hello Group,
>
> (still undusting and porting an old framework for reliable
> multicasting)
>
> the following (original) code processes an error (error C2036: 'void
> *' : unknown size)
>
> int cntcp;
> struct iovec *iov_set ;
>
> // ... (determine size of cntcp)
> iov_set->iov_base+=cntcp;
>
> well, I understand very well that this will turn into an error, but
> what do I do then? What was the original programmers goal? I guess he
> tries (tried) to read the information received from the multicastgroup
> and uses the cntcp variable to browse the iov_set->iov_base buffer.
> The problem is that you cannot add an int to a void *, I think you
> should add it to the address like this:
>
> iov_set->iov_base = cntcp + &iov_set->iov_base;
>
> this code doesnot give an error. Might my thinking be ok? Or does the
> fact that iov_set is already a pointer on itself complicate things?


That's very simple one:

((char *)iov-set->iov_base) += cntcp;

--
Lev Walkin
vlm@lionet.info
Wim Deprez

2004-07-28, 6:19 pm

Lev Walkin wrote:
> Wim Deprez wrote:
>

[...]
>
> That's very simple one:
>
> ((char *)iov-set->iov_base) += cntcp;
>


ah, I see it now :-) thanks a lot!,

--wim


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com