相关疑难解决方法(0)

如何修复gcc错误:在void之前预期

所以我正在编写一个使用pthreads来管理所有IO的点对点聊天客户端,当我编译文件时,gcc给了我错误

client.c: In function ‘accepted_daemon’:
client.c:115:1: error: expected ‘while’ before ‘void’
 void *
 ^
client.c: In function ‘listen_daemon’:
client.c:176:1: error: expected ‘while’ before ‘int’
 int main(int argc, char *argv[])
 ^
Run Code Online (Sandbox Code Playgroud)

我的程序的源代码是

#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
#include <assert.h>

#include <unistd.h>
#include <pthread.h>
#include <readline/readline.h>
#include <error.h>

#define error(s, e, ...) error_at_line (s, e, __FILE__, __LINE__, __VA_ARGS__)

#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netdb.h>

#define PORT 3248
#define PROMPT "message: "

struct accepted 
{
  int fd;
  struct …
Run Code Online (Sandbox Code Playgroud)

c gcc compiler-errors pthreads

3
推荐指数
1
解决办法
6046
查看次数

标签 统计

c ×1

compiler-errors ×1

gcc ×1

pthreads ×1