解答 解释warn_unused_result属性的作用: warn_unused_result属性是GCC编译器提供的一个警告特性,用于标记那些通常应该检查其返回值的函数。这些函数的返回值通常包含了函数执行状态的重要信息,比如是否成功执行、是否有错误发生等。如果调用了这样的函数但忽略了其返回值,编译器就会发出警告,提示开发者可能遗漏了重要的...
// Annotate a function indicating the caller must examine the return value.// Use like:// int foo() WARN_UNUSED_RESULT;// To explicitly ignore a result, see |ignore_result()| in base/macros.h.#undef WARN_UNUSED_RESULT#if defined(COMPILER_GCC) || defined(__clang__)#define WARN_UNUSE...
// Annotate a function indicating the caller must examine the return value.// Use like:// int foo() WARN_UNUSED_RESULT;// To explicitly ignore a result, see |ignore_result()| in base/macros.h.#undefWARN_UNUSED_RESULT#ifdefined(COMPILER_GCC)||defined(__clang__)#defineWARN_UNUSED_RESULT...
此时会有如下警告: 总结:如果一个方法的返回值比较重要,那么可以加__attribute__((warn_unused_result)) 来提醒开发人员检查返回值是否被使用。 添加一个链接:https://gcc.gnu.org/wiki/Visibility 作为参考
GCC (and some other compilers that emulate it) allows functions to be declared with __attribute__((warn_unused_result)). It then emits a warning on calls to this function that ignore its return value. We should use this attribute where warranted. In a common header (platform_util.h?),...
版权声明:本文为原创文章首发于公众号:六小登登 , 你可以随意转载但请务必注明出处!!!关注微信公众...
/* disable gcc's __attribute__((__warn_unused_result__)) since explicitly discarding the result by casting to (void) is not accepted as a 'use' */ discarding the result by casting to (void) is not accepted as a 'use'. This appears to be a problem for both Linux and M1 Macs...
从网上整理了一下Python忽略warning警告错误 方法一:直接运行脚本的时候加入参数 python -W ignore your...
/petsc-3.20.4/include/petscsystypes.h(66): warning #1835-D: attribute "warn_unused_result" does not apply here
pub const AUDIT_UNUSED_BITS: u32 = 134216704; pub const AUDIT_COMPARE_UID_TO_OBJ_UID: u32 = 1; pub const AUDIT_COMPARE_GID_TO_OBJ_GID: u32 = 2; pub const AUDIT_COMPARE_EUID_TO_OBJ_UID: u32 = 3; pub const AUDIT_COMPARE_EGID_TO_OBJ_GID: u32 = 4; pub const AUDIT_COMPARE_...