2
我用c写了一些代码,使用pthread(我首先在eclipse IDE中配置了链接器和编译器)。远程函数与pthread
#include <pthread.h>
#include "starter.h"
#include "UI.h"
Page* MM;
Page* Disk;
PCB* all_pcb_array;
void* display_prompt(void *id){
printf("Hello111\n");
return NULL;
}
int main(int argc, char** argv) {
printf("Hello\n");
pthread_t *thread = (pthread_t*) malloc (sizeof(pthread_t));
pthread_create(thread, NULL, display_prompt, NULL);
printf("Hello\n");
return 1;
}
工作正常。但是,当我将display_prompt移至UI.h 时,不会输出“Hello111”输出。
有人知道如何解决这个问题吗? Elad
我觉得没有明确返回0,而是有EXIT_SUCCESS。 – evilpie 2010-05-22 10:07:08
是的。并不是说它的价值永远不会改变,但它更加明确。 – Thomas 2010-05-22 21:00:34
谢谢。 我的问题是不同的:当所有的函数都在一个文件时,它工作正常。当将display_prompt()移动到其他文件时,它不起作用。 我添加了thread_join,但现在在同一个文件中的display_prompt()不起作用时。有没有一种特殊的方法来在Eclipse中进行调试? – 2010-05-23 11:53:22