error: unused parameter

本文介绍了一种常见的编程错误——编译器警告未使用的参数与变量,并提供了一个简单的解决方案:通过显式地忽略这些未使用的参数来消除警告。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


error: unused parameter

error: unused variable


fixed them as follow :
void foo(int a) {
    (void)a;
    // ...
}




[user@localhost HomeWork_makefile2]$ make gcc -std=c99 -Wall -Wextra -O2 -o threaded_server multi_threaded.c -lpthread multi_threaded.c: In function ‘send_error_response’: multi_threaded.c:81:5: warning: enumeration value ‘HTTP_200’ not handled in switch [-Wswitch] switch (status) { ^ gcc -std=c99 -Wall -Wextra -O2 -o process_server multi_process.c multi_process.c: In function ‘send_error_response’: multi_process.c:82:5: warning: enumeration value ‘HTTP_200’ not handled in switch [-Wswitch] switch (status) { ^ gcc -std=c99 -Wall -Wextra -O2 -o multiplexed_server io_multiplex.c io_multiplex.c: In function ‘bind_socket’: io_multiplex.c:6:22: warning: unused parameter ‘sockfd’ [-Wunused-parameter] void bind_socket(int sockfd) { /* 同multithreaded.c */ } ^ io_multiplex.c: In function ‘get_content_type’: io_multiplex.c:7:42: warning: unused parameter ‘path’ [-Wunused-parameter] const char* get_content_type(const char* path) { /* 同multithreaded.c */ } ^ io_multiplex.c: In function ‘is_path_safe’: io_multiplex.c:8:30: warning: unused parameter ‘path’ [-Wunused-parameter] int is_path_safe(const char* path) { /* 同multithreaded.c */ } ^ io_multiplex.c: In function ‘send_http_response’: io_multiplex.c:9:29: warning: unused parameter ‘client_fd’ [-Wunused-parameter] void send_http_response(int client_fd, http_status_t status, ^ io_multiplex.c:9:54: warning: unused parameter ‘status’ [-Wunused-parameter] void send_http_response(int client_fd, http_status_t status, ^ io_multiplex.c:10:37: warning: unused parameter ‘content_type’ [-Wunused-parameter] const char* content_type, off_t content_length) { /* 同multithreaded.c */ } ^ io_multiplex.c:10:57: warning: unused parameter ‘content_length’ [-Wunused-parameter] const char* content_type, off_t content_length) { /* 同multithreaded.c */ } ^ io_multiplex.c: In function ‘send_error_response’: io_multiplex.c:11:30: warning: unused parameter ‘client_fd’ [-Wunused-parameter] void send_error_response(int client_fd, http_status_t status) { /* 同multithreaded.c */ } ^ io_multiplex.c:11:55: warning: unused parameter ‘status’ [-Wunused-parameter] void send_error_response(int client_fd, http_status_t status) { /* 同multithreaded.c */ } ^ io_multiplex.c: In function ‘main’: io_multiplex.c:31:5: warning: missing braces around initializer [-Wmissing-braces] client_state_t clients[MAX_CLIENTS] = {0}; ^ io_multiplex.c:31:5: warning: (near initialization for ‘clients[0]’) [-Wmissing-braces] io_multiplex.c: In function ‘create_socket’: io_multiplex.c:5:1: warning: control reaches end of non-void function [-Wreturn-type] int create_socket() { /* 同multithreaded.c */ } ^ io_multiplex.c: In function ‘get_content_type’: io_multiplex.c:7:1: warning: control reaches end of non-void function [-Wreturn-type] const char* get_content_type(const char* path) { /* 同multithreaded.c */ } ^ io_multiplex.c: In function ‘is_path_safe’: io_multiplex.c:8:1: warning: control reaches end of non-void function [-Wreturn-type] int is_path_safe(const char* path) { /* 同multithreaded.c */ } ^ Web root prepared at webroot 这些报错信息什么意思
08-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值