警告:未使用计算的值

warning: value computed is not used

本文关键字:计算 未使用 警告      更新时间:2023-10-16

为什么在"BIO_flush(b64);"行收到警告消息"warning:value computed 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;
}

处理这些错误的常用方法是"显式抛出返回值"

(void) BIO_flush(b64);

或者,您可以通过添加-Wno-unused-value标志来选择同时关闭此警告。


上面显然假设您对返回值不感兴趣。如果您不确定,请查看文档中返回的确切内容,并决定是否要存储/使用它。