compiler-warnings

unchecked call to ArrayAdapter

那年仲夏 提交于 2019-11-30 07:52:20
I get the following warning when I instantiate my ArrayAdapter (compiles fine): warning: [unchecked] unchecked call to ArrayAdapter(android.content.Context,int,java.util.List<T>) as a member of the raw type android.widget.ArrayAdapter ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(CFAMain.this, android.R.layout.simple_spinner_dropdown_item, spinnerArray); And here's the problem line: ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(CFAMain.this, android.R.layout.simple_spinner_dropdown_item, spinnerArray); Anyone have any ideas as to why it's giving me this warning? That's because

“Delegate subtraction has unpredictable result” in ReSharper/C#?

耗尽温柔 提交于 2019-11-30 07:47:21
When using myDelegate -= eventHandler ReSharper (version 6) issues: Delegate subtraction has unpredictable result The rational behind this is explained by JetBrains here . The explanation makes sense and, after reading it, I'm doubting all my uses of - on delegates. How then , can I write a non-auto event without making ReSharper grumpy? or, is there a better and/or "correct" way to implement this? or, can I just ignore ReSharper? Here is simplified code: public delegate void MyHandler (object sender); MyHandler _myEvent; public event MyHandler MyEvent { add { _myEvent += value;

Compile-time constraint for complete pattern match

ぐ巨炮叔叔 提交于 2019-11-30 07:35:08
问题 I'm looking for the warning number for incomplete pattern matches. Anyone know what it is? More fully, I want to make FSC.EXE return incomplete pattern matches as compile-time errors rather than warnings + run-time exceptions. Does anyone know what the warning number for this is? Specifically, this relates to compiled .fs / interactive FSI .fsx REPL interaction. The warning: Incomplete pattern matches on this expression. For example, the value 'LaLaLa (_)' may indicate a case not covered by

#pragma warning disable & restore

∥☆過路亽.° 提交于 2019-11-30 06:54:32
问题 I have used c# to create a First Project. I have many warning errors and all these warning errors are to be single Error(Internal compiler error. See the console log for more information.) For Reducing the warning errors I used #pragma Warning disable . #pragma warning restore front and back of the problematic code. I have doubt that in my final build I should leave that #pragma warning disable & restore as it is in the program; or do I need to remove that? e.g: #pragma warning disable if

Disabling “bad function cast” warning

空扰寡人 提交于 2019-11-30 06:01:24
问题 I'm receiving the following warning: warning: converting from 'void (MyClass::*)(byte)' to 'void (*)(byte)' This is because I need to pass as argument a member function instead of an ordinary function. But the program is running correctly. I'd like to disable this warning (Wno-bad-function-cast doesn't work for C++) or to implement a different way to pass a member function. 回答1: No . Take this warning seriously. You should rather change your code to handle this scenario. Pointer to member

Can GCC warn me about modifying the fields of a const struct in C99?

六眼飞鱼酱① 提交于 2019-11-30 05:38:36
I stumbled upon a small issue while trying to make const-correct code. I would have liked to write a function that takes a pointer to a const struct, to tell to the compiler "please tell me if I am modifying the struct, because I really do not want to". It suddenly came to my mind that the compiler will allow me to do this: struct A { char *ptrChar; }; void f(const struct A *ptrA) { ptrA->ptrChar[0] = 'A'; // NOT DESIRED!! } Which is understandable, because what actually is const is the pointer itself, but not the type it points to. I would like for the compiler to tell me that I'm doing

Why do I get “warning: missing initializer for member”? [-Wmissing-field-initializers]

我们两清 提交于 2019-11-30 05:19:00
问题 I'm wondering why I am getting an warning about initialization in one case, but not the other. The code is in a C++ source file, and using GCC 4.7 with -std=c++11 . struct sigaction old_handler, new_handler; The above produces NO warnings with -Wall and -Wextra . struct sigaction old_handler={}, new_handler={}; struct sigaction old_handler={0}, new_handler={0}; The above produces warnings: warning: missing initializer for member ‘sigaction::__sigaction_handler’ [-Wmissing-field-initializers]

Significance of const keyword positioning in variable declarations

[亡魂溺海] 提交于 2019-11-30 05:02:08
What is the significance of the positioning of the const keyword when declaring a variable in Objective-C, for example: extern const NSString * MY_CONSTANT; versus extern NSString * const MY_CONSTANT; Using the first version in assignments produces warnings about "qualifiers from pointer target type" being discarded so I'm assuming that the second version ensures that the pointer address remains the same. I would really appreciate a more definitive answer though. Many thanks in advance! In the first case, you are declaring a mutable pointer to an immutable const NSString object, whereas in the

MSB3270: Mismatch between the processor architecture - Fakes Framework

醉酒当歌 提交于 2019-11-30 04:39:28
Since I use Fakes Framework in my UnitTest, I get the following MSBuild warning. warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "DocumentServiceModel", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor

Function overloading in C using GCC - compiler warnings

依然范特西╮ 提交于 2019-11-30 04:24:29
问题 I am attempting to implement function overloading in C , and I am very close. I am using C99 so the _Generic keyword introduced in C11 is not available to me. I have developed some working code, but when I compile it I get a couple warnings. Working example: #include <stdio.h> #define print(x) \ __builtin_choose_expr(__builtin_types_compatible_p(typeof(x), int ), print_int(x) , \ __builtin_choose_expr(__builtin_types_compatible_p(typeof(x), char[]), print_string(x), \ (void)0)) void print_int