[ace-users] error

Matthew Gillen mgillen at bbn.com
Mon Jul 9 08:40:35 CDT 2007


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



More information about the Ace-users mailing list