expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘struct’

这篇准备长期更新…


1.在编译时遇到错误
错误: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘struct’
src/cli_socket_handle.c: 在函数‘client_login’中:
...
  • 这种错误第一次遇到肯定很懵逼,根据多年的调试经验,很大可能是某个头文件不小心多打了某些没有意义的字符串,比如(倒数第二行多了个send):
    #ifndef CLI_SOCKET_HANDLE_H
    #define CLI_SOCKET_HANDLE_H
    #include "format.h"
    
    int send_file_head(int sockfd);
    send
    #endif //!CLI_SOCKET_HANDLE_H
    

2.下面这个错误
/usr/include/fcntl.h:211:12: 错误: 为形参‘posix_fadvise’指定了存储类
/usr/include/fcntl.h:233:12: 错误: 为形参‘posix_fallocate’指定了存储类
In file included from src/cli_socket_handle.c:15:0:
./libs/md5_sha2/include/sha2.h:22:2: 错误: 为形参‘Sha256State’指定了存储类
./libs/md5_sha2/include/sha2.h:25:17: 错误: expected declaration specifiers or ‘...’ before ‘Sha256State’
./libs/md5_sha2/include/sha2.h:26:18: 错误: expected declaration specifiers or ‘...’ before ‘Sha256State’
./libs/md5_sha2/include/sha2.h:27:17: 错误: expected declaration specifiers or ‘...’ before ‘Sha256State’
./libs/md5_sha2/include/sha2.h:28:19: 错误: expected declaration specifiers or ‘...’ before ‘Sha256State’
./libs/md5_sha2/include/sha2.h:32:15: 错误: 为形参‘Sha256Callback’指定了存储类
./libs/md5_sha2/include/sha2.h:33:22: 错误: expected declaration specifiers or ‘...’ before ‘Sha256Callback’
./libs/md5_sha2/include/sha2.h:37:21: 错误: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Sha224State’
./libs/md5_sha2/include/sha2.h:39:17: 错误: expected declaration specifiers or ‘...’ before ‘Sha256State’
./libs/md5_sha2/include/sha2.h:42:19: 错误: 未知的类型名‘Sha224State’
。。。
  • 别着急,这种大部分是因为头文件某个函数后面忘记加分号了,比如(倒数第二行函数声明后少了分号发现没):
    #ifndef CLI_SOCKET_HANDLE_H
    #define CLI_SOCKET_HANDLE_H
    #include "format.h"
    
    int send_file_head(int sockfd)
    #endif //!CLI_SOCKET_HANDLE_H
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值