c - expression must be a pointer to a complete object type from macro -
i'm attempting integrate libbeanstalkd embedded system i'm having make minor changes. far i've been able replace/fix os specific code came error. i've fixed these type of errors before "expression must pointer complete object type" what's getting me aside fact i'm sure header macro , used objects macro used few lines before compiler error thrown. can me understand issue is?
source arrayqueue.h
#ifndef arrayqueue_h #define arrayqueue_h #define aq_define_struct(struct_name, node_type) \ struct struct_name { \ node_type *nodes; \ size_t size; \ size_t used; \ off_t front; \ off_t rear; \ } #define aq_nodes_free(q) ( (q)->size - (q)->used ) #define aq_full(q) ( (q)->used == (q)->size ) #define aq_empty(q) ( (q)->used == 0 ) #define aq_rear_(q) ( (q)->nodes + (q)->rear ) #define aq_rear(q) ( aq_empty(q) ? null : aq_rear_(q) ) #define aq_front_(q) ( (q)->nodes + (q)->front ) #define aq_front(q) ( aq_full(q) ? null : aq_front_(q) ) #define aq_deq_fin(q) ( (q)->rear = ( (q)->rear + 1 ) % (q)->size, (q)->used-- ) #define aq_enq_fin(q) ( (q)->front = ( (q)->front + 1 ) % (q)->size, (q)->used++ ) #endif /* arrayqueue_h */
source ioqueue.h
:
#ifndef _ioqueue_h #define _ioqueue_h #include <stddef.h> #include <vsocket.h> #include "arrayqueue.h" #include "verixmissing.h" struct _ioq_node { struct iovec *vec; int autofree; }; aq_define_struct(_ioq, struct _ioq_node); typedef struct _ioq ioq; typedef struct _ioq_node ioq_node; #define ioq_nodes_ready(q) ((q)->used ? ( (q)->front <= (q)->rear ? (q)->size - (q)->rear : (q)->used ) : 0) #define ioq_peek_pos(q, i) ((aq_rear_(q)+i)->vec) #define ioq_rear_(q) ioq_peek_pos(q,0) #define ioq_rear(q) (aq_empty(q) ? null : ioq_rear_(q)) void ioq_enq_(ioq *q, void *data, ssize_t data_len, int autofree); int ioq_enq(ioq *q, void *data, ssize_t data_len, int autofree); ssize_t ioq_dump(ioq *q, int fd); ioq *ioq_new(size_t size); void ioq_free(ioq *q); #endif /* _ioqueue_h */
source ioqueue.c
:
#include <stdlib.h> #include <vsocket.h> #include "arrayqueue.h" #include "ioqueue.h" ... ssize_t ioq_dump(ioq *q, int fd) { size_t bytes_expected = 0, nodes_ready = ioq_nodes_ready(q), i; ssize_t bytes_written, nodes_written = 0; (i = 0; < nodes_ready; ++i) bytes_expected += ioq_peek_pos(q,i)->iov_len; if ( ( bytes_written = writev(fd, ioq_rear_(q), nodes_ready) ) < bytes_expected ) switch (bytes_written) { case -1: return -1; default: while ( ( bytes_written -= ioq_rear_(q)->iov_len ) > 0 ) { ioq_dump_fin(q, 1); ++nodes_written; } if ( bytes_written < 0 ) { ioq_rear_(q)->iov_base += ioq_rear_(q)->iov_len + bytes_written; ^---------------------- error! ioq_rear_(q)->iov_len = -bytes_written; } return nodes_written; } else { ioq_dump_fin(q, nodes_ready); return nodes_ready; } }
error:
"..\source\libs\libbeanstalkd\ioqueue.c", line 125: error: #852: expression must pointer complete object type ioq_peek_pos(q, 0)->iov_base += ioq_rear_(q)->iov_len + bytes_written; ^
if helps, eclipse expands macro to: ((( (q)->nodes + (q)->rear )+0)->vec)
it possible struct iovec not defined in code somehow.
struct _ioq_node { struct iovec *vec; // <-------- int autofree; };
dump preprocessor output , check definition. take gcc command line , replace -c option -e (and set -o wherever want output go).
gcc -e -o <op> ...