lint 会产生一些警告,例如:
foo.c XXX Warning 534: Ignoring return value of function bar()
来自 lint manual
534 Ignoring return value of function
'Symbol' (compare with Location) A function that returns a value is called just for side effects as, for example, in a statement by itself or the left-hand side of a comma operator. Try: (void) function(); to call a function and ignore its return value. See also the fvr, fvo and fdr flags in §5.5 "Flag Options".
我想在编译期间收到此警告(如果存在)。 gcc/g++ 中是否有任何选项可以实现这一点?我打开了 -Wall
但显然没有检测到这一点。
最佳答案
关于c++ - g++如何在忽略函数返回值时获得警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2870529/