- 论坛徽章:
- 0
|
在Fedora9 环境下, POSIX多线程程序设计 一书中某程序代码如下:
/* errors.h*/
#ifndef __errors_h
#define __errors_h
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef DEBUG
# define DPRINTF(arg) printf arg
#else
# define DPRINTF(arg)
#endif
#define err_abort(code,text) do { \
fprintf (stderr, "%s at \"%s\":%d: %s\n", \
text, __FILE__, __LINE__, strerror(code)); \ abort (); \
} while (0)
#define errno_abort(text) do { \
fprintf (stderr, "%s at \"%s\":%d: %s\n", \
text, __FILE__, __LINE__, strerror (errno)); \
abort (); \
} while (0)
#endif
/*hello.c */
#include <pthread.h>
#include "errors.h"
void *hello_world (void *arg){ printf ("Hello world\n");
return NULL;}
int main (int argc, char *argv[])
{
pthread_t hello_id;
int status;
status = pthread_create (&hello_id, NULL, hello_world, NULL);
if (status != 0) err_abort (status, "Create thread");
status = pthread_join (hello_id, NULL);
if (status != 0) err_abort (status, "Join thread");
return 0;
}
问题主要出在 errors.h中 ,用gcc编译时,系统总是提示:_FILE 未声明,_LINE_未声明,但是没找到出错原因,敬请高手指点 |
|