简体   繁体   English

在Xcode中没有匹配的函数调用'pthread_create'

[英]No matching function call to 'pthread_create' in Xcode

No matching function call to 'pthread_create' 没有匹配的函数调用'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 gives me the error, "No matching function call to 'pthread_create'". Xcode给我错误,“没有匹配的函数调用'pthread_create'”。 I dont know what i'm doing wrong. 我不知道我在做什么错。 Any help would be greatly appreciated. 任何帮助将不胜感激。

I was able to get it to compile but i am now getting this message. 我能够将其编译,但现在却收到此消息。 I do not know what the problem is. 我不知道问题是什么。 thread 1, Queue : com.apple.main-thread 线程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

The signature of your producer and consumer functions should be as follows: 生产者和消费者功能的签名应如下:

void *Producer(void *data);
void *Consumer(void *data);

I believe you are required to pass the attributes parameter as well. 我相信您也需要传递attribute参数。 See Apple's Documentation for a good example. 有关示例,请参阅Apple文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM