[ace-users] error

Albert Sanchez ouferrat at gmail.com
Mon Jul 9 09:50:20 CDT 2007


Thank you Matt,

I thought that the iovec definition was another. I saw it in page 66
of the book "C++ Network  Programming. Mastering Complexity with ACE
and Patterns."



On 09/07/07, Matthew Gillen <mgillen at bbn.com> wrote:
> Albert Sanchez wrote:
> > Does anyone know the reason of this error?
> >
> > -
> > server.cpp: In function â:
> > server.cpp:74: error: pointer of type â used in arithmetic
> > server.cpp:74: error: â is not a pointer-to-object type
> > server.cpp:79: warning: deleting â is undefined
> > make: *** [server] Error 1
> > -
> >
> > The code is (lines 73-79):
> >
> > -
> > for (int j=0; j<(int)vec->iov_len; j++) {
> >   printf("%c",*(vec->iov_base[j]));
> >
> > where iovec is defined globally:
> >
> > iovec * vec;
>
> You're doing several things wrong here, and none have to do with ACE really,
> but I'm a nice guy, so:
> > server.cpp:74: error: pointer of type â used in arithmetic
> An iovec is defined as:
>          struct iovec {
>              void *iov_base;   /* Starting address */
>              size_t iov_len;   /* Number of bytes */
>          };
> Note the 'void' pointer.  You cannot use pointer arithmetic (ie the '[i]'
> syntax) with a void pointer since the complier doesn't know where the element
> boundaries are, so you need to cast the pointer to the correct type first.
>
> > server.cpp:74: error: â is not a pointer-to-object type
>
> You need to lose the '*' on line 74.  The bracket syntax does not return a
> pointer that you need to dereference.
>
> > server.cpp:79: warning: deleting â is undefined
> I'm guessing casting to the appropriate pointer type will help here too.
>
> HTH,
> Matt
>


-- 
"Computer science is no more about computers than astronomy is about
telescopes."
Edsger Dijkstra



More information about the Ace-users mailing list