compiler-warnings

GCC -Wunused-function not working (but other warnings are working)

僤鯓⒐⒋嵵緔 提交于 2020-01-14 10:13:24
问题 I'm trying to find unused functions in my codebase by using GCC's -Wunused-function flag. As I would expect, compiling the below code with gcc -Wall -Wunused-function main.cpp prints an unused variable warning: warning: unused variable ‘x’ [-Wunused-variable] However, the compiler doesn't give an unused-function warning. What do I have to do to make GCC notice the unused function foo() ? // main.cpp void foo(){ } //should (but doesn't) trigger 'unused function' warning int main (int argc,

How to handle unused warnings caused by empty template parameter pack expansions?

若如初见. 提交于 2020-01-14 07:03:14
问题 An issue I keep facing is one where the compiler complains about an unused variable, even though the variable is used, but it's only used inside a parameter pack expansion that happens to be empty for a specific instantiation. For example: template <std::size_t... I> auto func1(std::index_sequence<I...>) { auto var = get_tuple(); return func2(std::get<I>(var)...); } auto a = func1(std::make_index_sequence<0>()); See live example (try changing the tuple at line 4, by adding an int inside <> to

Using UNREFERENCED_PARAMETER macro

故事扮演 提交于 2020-01-13 08:47:31
问题 I'm using \W4 warning level on Visual Studio and I'm writing a Windows program. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) All these parameters are not used in my application, so I get warnings at compile time. I know there are two ways of dealing with this: Commenting parameters HINSTANCE /*hInstance*/ ... Using the UNREFERENCED_PARAMETER macro int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)

C# Bitwise-or operator used on a sign-extended operand; consider casting to a smaller unsigned type first

南楼画角 提交于 2020-01-12 11:48:54
问题 I know these warnings are probably pointless.. But anyway I could get rid of them? I got 7 of these warnings. Bitwise-or operator used on a sign-extended operand; consider casting to a smaller unsigned type first This has something to do with the OR operator | I highlighted what gives off the warnings. int result = (int)ror((uint)(v76 ^ (v75 | 0x862D63D3)), (uint)(BitConverter.ToInt32(v4, 72) ^ 0x22)); int v11 = (int)rol((uint)(int)((v8 & v10 | ~v10 & 0xEFCDAAC9) + v3[2] - 1126481991), 17);

How to suppress warnings in Xcode?

我的梦境 提交于 2020-01-12 08:43:34
问题 In Xcode 5, is there any way to suppress warnings such as unused variables for number of files? Particularly latest Box2D 2.2.1 produces some warnings which are annoying but harmless. 回答1: Select the project in the navigator, then select the target from the list. Select the Build Phases tab, then expand the Compile Sources phase. The Compiler Flags column is where you specify per-file compiler flags. Enter -Wno- to negate a warning. e.g.: -Wno-unused-parameter 回答2: You can add a compiler flag

How do I quiet the C compiler about a function pointer takes any number of arguments?

ぐ巨炮叔叔 提交于 2020-01-11 03:13:07
问题 I have a function pointer inside a struct that gets dynamically set at runtime to the address of another function in various places in my code. It is defined in my header file like this: void *(*run)(); During compile time, I get the following warning about this: warning: function declaration isn't a prototype This warning is benign, because the pointer is used in many places in my code to call the function it points to, and everything works just fine. However, I would really like to silence

Conditionally disable warnings with qmake/gcc?

无人久伴 提交于 2020-01-10 19:42:08
问题 I am involved with a software project written in Qt and built with qmake and gcc on Linux. We have to link to a third-party library that is of fairly low quality and spews tons of warnings. I would like to use -W -Wall on our source code, but pass -w to the nasty third-party library to keep the console free of noise and clutter so we can focus on our code quality. In qmake, is there a way to conditionally add CFLAGS/CXXFLAGS to certain files and libraries? 回答1: Jonathan, I think the problem

Why compiler is not giving error when signed value is assigned to unsigned integer? - C++

二次信任 提交于 2020-01-10 00:52:11
问题 I know unsigned int can't hold negative values. But the following code compiles without any errors/warnings. unsigned int a = -10; When I print the variable a , I get a wrong value printed. If unsigned variables can't hold signed values, why do compilers allow them to compile without giving any error/warning? Any thoughts? Edit Compiler : VC++ compiler Solution Need to use the warning level 4. 回答1: Microsoft Visual C++: warning C4245: 'initializing' : conversion from 'int' to 'unsigned int',

Stack - unchecked/unsafe operations

痴心易碎 提交于 2020-01-05 04:17:07
问题 So I'm trying to run this simple program here: import java.util.*; class StackDemo { public static void main(String[] args) { Stack s = new Stack(); s.push(5); s.push("dog"); System.out.print(s); } } StackDemo.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Process completed. It displays the expected result, which is "[5, dog]" but I don't understand that message on the Build Output window. What could possibly be wrong here? 回答1: Stack is a generic

Warning when comparing references to bool and int with MSVC 2015

限于喜欢 提交于 2020-01-03 06:50:10
问题 The following code produces a warning with MSVC (2015 Update 3) - with /W4 : const bool& a = true; const int& b = 1; if(a == b) C4805: '==': unsafe mix of type 'const bool' and type 'const int' in operation but without the references it compiles cleanly. const bool a = true; const int b = 1; if(a == b) WHY? EDIT: just tested without const as well bool a = true; int b = 1; if(a == b) and the warning reappeared... EDIT 2: Compiling in Debug... I did have to silence C4127: conditional expression