compiler-warnings

Disabling “bad function cast” warning

て烟熏妆下的殇ゞ 提交于 2019-11-28 13:24:55
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. No . Take this warning seriously. You should rather change your code to handle this scenario. Pointer to member function( void (MyClass::*)(byte) ) and normal function pointer ( void (*)(byte) ) are entirely different. See

Using '!' here is deprecated and will be removed in a future release - swift 4.2

半世苍凉 提交于 2019-11-28 13:05:11
Compiler throwing following warning when setting image in a cell using SDWebimage in Swift 4.2. Swift Compiler warning : Using '!' here is deprecated and will be removed in a future release let url = NSURL(string: (str_url) as String) cell.img!.sd_setImage(with: url as URL!, completed: block_image) //--- WARNING ON THIS LINE AT URL! Any Suggestions ? Use this code : cell. img!.sd_setImage(with: url! as URL, completed: block_image) Suggestion: use URL instead of NSURL let url = URL(string: "" ) //use url String cell.img!.sd_setImage(with: url, completed: block_image) Try this: if let url = URL

How to suppress or ignore all warnings in Xcode?

坚强是说给别人听的谎言 提交于 2019-11-28 12:56:48
Does anyone know how to suppress all warnings in Xcode 7? I've tried pragmas and compiler flags... nothing works First of all, it's a really bad idea: warnings exist for a reason , you really should check each of them. But... you want suppress every warning or just a few types there's a way, check these easy steps and turn off all or just what you need: 1) search for "show warning" in your build settings 2) under build settings search for Apple LLVM 7.0 - Warnings - All languages 来源: https://stackoverflow.com/questions/33111048/how-to-suppress-or-ignore-all-warnings-in-xcode

C#: Is pragma warning restore needed?

巧了我就是萌 提交于 2019-11-28 11:52:23
From msdn I get this: #pragma warning disable warning-list #pragma warning restore warning-list In the examples, both disable and restore are used. Is it necessary to restore if I want it disabled for a whole file? Like, if I do not restore, how far does it carry? Are the warnings disabled for everything compiled after that? Or just for the rest of that file? Or is it ignored? If you do not restore the disabling is active for the remainder of the file. Interestingly this behaviour is not defined in the language specification . (see section 9.5.8) However the 9.5.1 section on Conditional

Deprecated conversion from string constant to char * error [duplicate]

ぐ巨炮叔叔 提交于 2019-11-28 11:42:29
Possible Duplicate: C++ deprecated conversion from string constant to ‘char*’ I am having following code, though i didn't copy full code because it is huge. Following code is in template class, and i am getting warning as below. Because of warning in template i am not able to instantiate it and getting "instantiated from here" error. warning: deprecated conversion from string constant to 'char*'' void ErrorMessageInRaphsodyCode(char* pcCompleteMessage, char* pcMessage, char* pcFileName, unsigned int RowNo) { //... } char cCompleteMessage[200]; memset(cCompleteMessage, 0x00, sizeof

C++: warning: C4930: prototyped function not called (was a variable definition intended?) [duplicate]

余生长醉 提交于 2019-11-28 10:15:47
This question already has an answer here: Is there any difference between `List x;` and `List x()` 1 answer I have a class that does not have a default constructor, I created a variable without giving parameters by mistake, but instead of a nice compiler error, I got a linker error, where I couldn't find the line of code that was causing it. In the end, I managed to find the code that caused this, and only then I noticed that I was getting this warning: C++: warning: C4930: prototyped function not called (was a variable definition intended?) What's weird is when I changed the code from:

Is it problematic to assign a new value to a method parameter?

こ雲淡風輕ζ 提交于 2019-11-28 09:42:55
Eclipse has an option to warn on assignment to a method's parameter (inside the method), as in: public void doFoo(int a){ if (a<0){ a=0; // this will generate a warning } // do stuff } Normally I try to activate (and heed) almost all available compiler warnings, but in this case I'm not really sure whether it's worth it. I see legitimate cases for changing a parameter in a method (e.g.: Allowing a parameter to be "unset" (e.g. null) and automatically substituting a default value), but few situations where it would cause problems, except that it might be a bit confusing to reassign a parameter

Java Generics, how to avoid unchecked assignment warning when using class hierarchy?

前提是你 提交于 2019-11-28 09:22:04
I want to use a method using generic parameters and returning generic result on a class hierarchy. edit: no SupressWarnings("unchecked") answer allowed :-) Here is a sample code illustrating my problem: import java.util.*; public class GenericQuestion { interface Function<F, R> {R apply(F data);} static class Fruit {int id; String name; Fruit(int id, String name) { this.id = id; this.name = name;} } static class Apple extends Fruit { Apple(int id, String type) { super(id, type); } } static class Pear extends Fruit { Pear(int id, String type) { super(id, type); } } public static void main

array subscript has type 'char'

旧时模样 提交于 2019-11-28 09:13:49
问题 I have the following code to read an argument from the command line. If the string is 1 character long and a digit I want to use that as the exit value. The compiler gives me a warning on the second line (array subscript has type 'char' ) This error comes from the second part after the "&&" . if (args[1] != NULL) { if ((strlen(args[1]) == 1) && isdigit(*args[1])) exit(((int) args[1][0])); else exit(0); } } Also, when I use a different compiler I get two errors on the next line (exit). builtin

How to suppress Java compiler warnings for specific functions

夙愿已清 提交于 2019-11-28 08:59:10
We are always taught to make sure we use a break in switch statements to avoid fall-through. The Java compiler warns about these situations to help us not make trivial (but drastic) errors. I have, however, used case fall-through as a feature (we don't have to get into it here, but it provides a very elegant solution). However the compiler spits out massive amounts of warnings that may obscure warnings that I need to know about. I know how I can change the compiler to ignore ALL fall-through warnings, but I would like to implement this on a method-by-method basis to avoid missing a place where