没有匹配的函数调用'pthread_create'
# include <stdio.h>
# include <pthread.h>
string nextProduced;
string nextConsumed;
char *BUFFER;
int BufferSize = 10;
void putItemIntoBuffer();
string produceItem();
string consumeItem();
void *Producer();
void *Consumer();
pthread_cond_t Buffer_Not_Full=PTHREAD_COND_INITIALIZER;
pthread_cond_t Buffer_Not_Empty=PTHREAD_COND_INITIALIZER;
pthread_mutex_t mVar=PTHREAD_MUTEX_INITIALIZER;
int main()
{
pthread_t pro, con;
BUFFER=(char *) malloc(sizeof(char) * BufferSize);
pthread_create(&pro,NULL,Producer,NULL);// Creates threads
pthread_create(&con,NULL,Consumer,NULL);// Creates threads
pthread_join(pro,NULL);
pthread_join(con,NULL);
return 0;
}
Xcode给出了错误,“没有匹配函数调用'pthread_create'”。我不知道我做错了什么。任何帮助将不胜感激。
我能够将其编译,但我现在收到此消息。 我不知道问题是什么。 线程1,队列:com.apple.main-thread
libsystem_c.dylib`strlen:
0x7fff8d8364e0: pxor %xmm0, %xmm0
0x7fff8d8364e4: movl %edi, %ecx
0x7fff8d8364e6: movq %rdi, %rdx
0x7fff8d8364e9: andq $-16, %rdi
0x7fff8d8364ed: orl $-1, %eax
0x7fff8d8364f0: pcmpeqb(%rdi), %xmm0 Thread 1:EXC_ACCESS (code=1, address=0x0) //line in question
0x7fff8d8364f4: andl $15, %ecx
0x7fff8d8364f7: shll %cl, %eax
0x7fff8d8364f9: pmovmskb%xmm0, %ecx
0x7fff8d8364fd: andl %eax, %ecx
0x7fff8d8364ff: je 0x7fff8d83650b ; strlen + 43
0x7fff8d836501: bsfl %ecx, %eax
0x7fff8d836504: subq %rdx, %rdi
0x7fff8d836507: addq %rdi, %rax
0x7fff8d83650a: ret
0x7fff8d83650b: pxor %xmm0, %xmm0
0x7fff8d83650f: addq $16, %rdi
0x7fff8d836513: movdqa (%rdi), %xmm1
0x7fff8d836517: addq $16, %rdi
0x7fff8d83651b: pcmpeqb%xmm0, %xmm1
0x7fff8d83651f: pmovmskb%xmm1, %ecx
0x7fff8d836523: testl %ecx, %ecx
0x7fff8d836525: je 0x7fff8d836513 ; strlen + 51
0x7fff8d836527: subq $16, %rdi
0x7fff8d83652b: jmp 0x7fff8d836501 ; strlen + 33
答案 0 :(得分:0)
生产者和消费者功能的签名应如下:
void *Producer(void *data);
void *Consumer(void *data);
我相信你也需要传递属性参数。请参阅Apple's Documentation以获取一个好例子。