定义:struct sigaction act;
编译:gcc server.c wrap.c -o server -std=c99
错误:
act的存储大小未知
server.c:56: 错误:‘act’的存储大小未知
server.c:58: 警告:隐式声明函数‘sigemptyset’
server.c:61: 警告:隐式声明函数‘sigaction’
解决办法:编译时去掉 -std=c99;
套接字编程:
错误内容:accept error: Bad file descriptor解决办法:查找是否将套接字关掉
线程程序编译出错
server.c:(.text+0x315): undefined reference to `pthread_create’
pthread 库不是 Linux 系统默认的库,连接时需要使用静态库
libpthread.a,所以在使用pthread_create()创建线程,要链接该库。问题解决:
在编译中要加 -lpthread参数 gcc server.c -o server -lpthread
warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
exit(0);
原因:出现这个警告的原因是没有将exit函数定义的头文件stdlib.h包含进来。
通过man exit 可以看到exit函数的手册。
NAME
exit - cause normal process termination
SYNOPSIS
#include <stdlib.h>
void exit(int status);