小编Par*_*dox的帖子

我很难使用多个文件进行结构化工作.请帮忙?

我正在尝试解决消费者/生产者问题,我必须创建三个不同的类.

主类包括线程的创建和消费者/生产者逻辑

另外两个类是

  • 环形缓冲区的头文件
  • 包含环形缓冲区实现的文件

我在尝试编译时遇到以下错误:

ringbuf.c: In function ‘rb_init’:
ringbuf.c:10: warning: incompatible implicit declaration of built-in function ‘malloc’
ringbuf.c:10: error: invalid application of ‘sizeof’ to incomplete type ‘struct ringbuf_t’ 
ringbuf.c:12: error: dereferencing pointer to incomplete type
Run Code Online (Sandbox Code Playgroud)

我还有很多其他的错误,但是一旦我完成这个错误,我就可以自己处理.

这是缓冲区的头文件:

struct ringbuf_t 
{
    pthread_mutex_t mutex; /* lock to protect from simutaneous access to the buffer */
    pthread_cond_t cond_full; /* producer needs to wait when the buffer is full */
    pthread_cond_t cond_empty; /* consumer needs to wait when the buffer is empty …
Run Code Online (Sandbox Code Playgroud)

c unix pthreads header-files

1
推荐指数
1
解决办法
247
查看次数

标签 统计

c ×1

header-files ×1

pthreads ×1

unix ×1