这篇准备长期更新…
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