【发布时间】:2015-06-06 08:56:14
【问题描述】:
请您帮我解决以下演员表错误。这是我的代码:
int (*hook_parse) (netsnmp_session *, netsnmp_pdu *,u_char *, size_t);
.
.
netsnmp_pdu* tpdu=NULL;
.
.
char buf[65537]="", sep='|', sep1[]="bc_sep1";
.
.
buf[tpdu->community_len] =sep;
buf[tpdu->community_len] =sep1; //This Line gives error
我得到的错误是:
api.c:: warning: assignment makes integer from pointer without a cast
对于 sep 我没有收到这样的错误,但是对于字符串 sep1,我遇到了上述错误。
【问题讨论】:
-
int netsnmp_pdu * ;that 究竟应该是什么?你的意思是int *netsnmp_pdu;吗?或者typedef int *netsnmp_pdu;?无论如何,sep是char,sep1是char[8],它们在类型上并不是表达式(或其他任何东西)的同义词。 -
它到底是哪一行给出了警告?
community_len声明为什么?请详细说明。 -
这是因为
buf[tpdu->community_len]是char,所以用sep分配它也是char(类似类型)是可以的。但是sep1是char*。 -
您需要再编辑一次;您告诉我们触发错误的行应该在做什么。你想用那行代码做什么?
-
无论你做什么,不要添加演员表来消除警告。
标签: c pointers casting type-conversion