compiler-warnings

casting a pointer to integer issues warning on 64bit arch

天涯浪子 提交于 2019-12-07 09:16:31
问题 I'm writing a linux kernel module that makes use of the exported symbol open_exec struct file *open_exec(const char *name) It returns a pointer, and I can check for an error with the IS_ERR macro: if (IS_ERR(file)) return file; During compile time, I get this warning: warning: return makes integer from pointer without a cast This is because my function here returns an integer. If I try to cast it: return (int) file; I don't get a warning on my 32bit machine, but I do on my 64bit machine:

Adding all images to the Package.AppXManifest results in a compiler warning

て烟熏妆下的殇ゞ 提交于 2019-12-07 08:38:55
问题 I have specified win8_logo_small.png for the "Small logo" in the Package.appxmanifest setting of my Windows 8 Store project. When I create a store package, I get this warning: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\AppxPackage\Microsoft.AppXPackage.Targets(1052,9): warning APPX1621: A mixture of images matching logical name 'win8_logo_small.png' exists in this project with and without the "scale" or "targetsize" qualifier specified. For predictable runtime behavior,

Where to add -Wall and -Wextra in Xcode 3.1.4

喜夏-厌秋 提交于 2019-12-07 07:43:07
问题 I'm trying to figure out where to add extra warning flags like -Wall and -Wextra in Xcode, I'm using version 3.1.4 on Leopard. Apple's documentation is for an old version, if I follow their instructions it takes me to a completely different window than what they show. Also they have a screenshot of a checklist of specific warning flags, I can't figure out how to get to that or even if that's still around. CLARIFICATION: I'm building an iPhone app... bbum pointed me to the right spot for an OS

Dealing with deprecated methods in iPhone

自闭症网瘾萝莉.ら 提交于 2019-12-07 06:56:20
问题 How do you deal with deprecated methods in iPhone that require you to use a newer method, not available in older versions? Consider the case of setStatusBarHidden:animated: , which was deprecated in iOS 3.2. The documentation points you to use setStatusBarHidden:withAnimation: , which is only available in iOS 3.2 or later. If I understand correctly, this means that to target all devices (iOS 3.0 or later), I have to ask first if setStatusBarHidden:withAnimation: is available. If it is, use it

Java: properly checked class instantiation using reflection

▼魔方 西西 提交于 2019-12-07 05:37:01
问题 I'm trying to use one of the simplest forms of reflection to create an instance of class: package some.common.prefix; public interface My { void configure(...); void process(...); } public class MyExample implements My { ... // proper implementation } String myClassName = "MyExample"; // read from an external file in reality Class<? extends My> myClass = (Class<? extends My>) Class.forName("some.common.prefix." + myClassName); My my = myClass.newInstance(); Typecasting unknown Class object we

Telling gcc diagnostics apart

独自空忆成欢 提交于 2019-12-07 05:30:30
问题 I have a problem interpreting gcc (4.8.2) warnings & errors. More precisely, it's difficult to tell where one problem ends and another one starts. I have console-only access to the build machine, so using an IDE is not an option. I really need to be able to tell individual issues apart quickly. Is there a way to make GCC insert something between distinct diagnostic messages? Here is an example output I am getting: /usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/src

Undefined/Unspecified/Implementation-defined behaviour warnings?

喜夏-厌秋 提交于 2019-12-07 04:54:48
问题 Can't a compiler warn (even better if it throws errors) when it notices a statement with undefined/unspecified/implementation-defined behaviour? Probably to flag a statement as error, the standard should say so, but it can warn the coder at least. Is there any technical difficulties in implementing such an option? Or is it merely impossible? Reason I got this question is, in statements like a[i] = ++i; won't it be knowing that the code is trying to reference a variable and modifying it in the

Is it possible to disable specific compiler warnings?

冷暖自知 提交于 2019-12-07 04:08:31
问题 I am trying to suppress specific compiler warnings, namely System.Data.OracleClient.OracleConnection' is obsolete . I came upon these questions here: How to disable specific warnings for the entire solution? Globally suppress c# compiler warnings ...but they don't seem to apply to VS2013. When I go to my project's properties, I don't see a Build tab. I see a Compile tab, but it doesn't appear to have a place to specify warning messages to suppress. I see a section there called Warning

Scala warning match may not be exhaustive

江枫思渺然 提交于 2019-12-07 03:50:43
问题 I am somewhat new to Scala. Following is my code. Option(Session.get().getAttribute("player")) match { case None => { val player = new Player(user.getEmail, user.getNickname).createOrGet Session.get().setAttribute("player", player) } } I get the following warning when compiling Warning:(35, 11) match may not be exhaustive. It would fail on the following input: Some(_) Option(Session.get().getAttribute("player")) match { ^ How do I fix this? Is there a way to rewrite the code to avoid the

What is the purpose of gcc's -Wbad-function-cast?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 02:25:23
问题 As advised by an answer here, I turned on -Wbad-function-cast to see if my code had any bad behavior gcc could catch, and it turned up this example: unsigned long n; // ... int crossover = (int)pow(n, .14); (it's not critical here that crossover is an int ; it could be unsigned long and the message would be the same). This seems like a pretty ordinary and useful example of a cast. Why is this problematic? Otherwise, is there a reason to keep this warning turned on? I generally like to set a