编写gSoap XML/RPC程序时出现“soapStub.h: error: redefinition of parameter ‘soap’”

本文解决了gSOAP XML/RPC+C编程中因参数重复定义导致的编译错误问题。通过调整参数列表并正确处理客户端和服务端的接口定义,确保了程序能够顺利编译。

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

最近使用gSOAP XML/RPC + C代码编写我的测试程序,编译时出现“soapStub.h: error: redefinition of parameter ‘soap’”。

[root@localhost src]# make iclient
gcc -o iclient iclient.c wsi2c.h soapClient.c soapC.c base.c base.h -lgsoap
In file included from soapH.h:13:0,
                 from iclient.c:12:
soapStub.h:255:132: error: redefinition of parameter ‘soap’
 SOAP_FMAC5 int SOAP_FMAC6 soap_call_ns__myset(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct soap *soap, char *bus, char *devaddr, int reg, int data, int *result);

根据提示,soap_call_ns__myset(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct soap *soap, char *bus, char *devaddr, int reg, int data, int *result),注意到了soap_call_ns__myset函数的参数出现了两个struct soap*soap,因此报此错。

解决方法是将iws.h文件直接删除struct soap *soap即可。

int ns__myset(struct soap *soap,char *bus, char *devaddr, int reg, int data, int *result);


如果服务器端需要使用struct soap *soap结构体指针,那就在服务器端程序中添加即可。例如:

1、iws.h

int ns__myset(char *bus, char *devaddr, int reg, int data, int *result);

2、iserver.c

int ns__myset(struct soap *soap, char *bus, char *devaddr, int reg, int data, int *result);


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值