为什么我会在“BIO_flush(b64);”行上看到警告消息“warning:value calculated is not used”我该如何摆脱它?警告:未使用计算出的值
unsigned char *my_base64(unsigned char *input, int length)
{
BIO *bmem, *b64;
BUF_MEM *bptr;
b64 = BIO_new(BIO_f_base64());
bmem = BIO_new(BIO_s_mem());
b64 = BIO_push(b64, bmem);
BIO_write(b64, input, length);
BIO_flush(b64);
BIO_get_mem_ptr(b64, &bptr);
unsigned char *buff = (unsigned char *)malloc(bptr->length+1);
memcpy(buff, bptr->data, bptr->length-1);
buff[bptr->length-1] = 0;
BIO_free_all(b64);
return buff;
}
'BIO_flush()'可能被声明为返回某些内容,但不会将结果存储在任何地方或在表达式中使用。 – jrok 2012-04-02 13:57:52
BIO_flush()将被声明为一个计算值的宏。由于结果未分配给变量,因此您将收到此警告。我认为如果BIO_flush是一个真正的函数,这个警告就不会发生。我认为要避免警告下面 - 你需要分配给临时 – 2012-04-02 14:06:53
'BIO_flush'也可以是一个扩展到一个逗号运算符表达式的宏,其中逗号运算符的左侧没有副作用。尽管没有看到“BIO_flush”的定义,但所有这些只是猜测。 – celtschk 2012-04-02 14:09:55