compiler-warnings

Java warning: [unchecked] unchecked conversion

痴心易碎 提交于 2019-12-30 12:38:48
问题 I have the following (partial) class: public class Graph<O> { private ArrayList<Edge> edges; public ArrayList<Edge> getEdges() { return edges; } } Now, when calling the method getEdges() somewhere else and storing the result in a variable of type ArrayList<Edge> , I get warning: [unchecked] unchecked conversion : OtherFile.java:101: warning: [unchecked] unchecked conversion ArrayList<Edge> edges = graph.getEdges(); ^ required: ArrayList<Edge> found: ArrayList I have looked at multiple other

Visual Studio 2013 Compiler Warnings not Showing

断了今生、忘了曾经 提交于 2019-12-30 11:09:32
问题 I installed Visual Studio 2013 last night and I'm noticing that it's not showing any warnings at all. Specifically, I want it to highlight unused local variables, private methods and the like. Is there a setting somewhere in Visual Studio that I need to enable? 回答1: I ran into the solution by coincidence. - Right click on your project a select "Properties". - Go to the "Code Analysis" tab on the left. - Change the Rule Set to "Microsft All Rules". I had it set to "Microsft Managed Recommended

Can I get PyCharm to suppress a particular warning on a single line?

删除回忆录丶 提交于 2019-12-30 05:32:27
问题 PyCharm provides some helpful warnings on code style, conventions and logical gotchas. It also provides a notification if I try to commit code with warnings (or errors). Sometimes I consciously ignore these warnings for particular lines of code (for various reasons, typically to account for implementation details of third-party libraries). I want to suppress the warning, but just for that line (if the warning crops up on a different line where I'm not being deliberate, I want to know about it

How does scoped_lock avoid emitting an “unused variable” warning?

╄→гoц情女王★ 提交于 2019-12-30 03:55:09
问题 boost::mutex::scoped_lock is a handy RAII wrapper around locking a mutex. I use a similar technique for something else: a RAII wrapper around asking a data interface to detach from/re-attach to a serial device. What I can't figure out, though, is why in the code below only my object mst — whose instantiation and destruction do have side effects — causes g++ to emit an "unused variable" warning error whereas l manages to remain silent. Do you know? Can you tell me? [generic@sentinel ~]$ cat

assert() with message

浪尽此生 提交于 2019-12-29 13:43:46
问题 I saw somewhere assert used with a message in the following way: assert(("message", condition)); This seems to work great, except that gcc throws the following warning: warning: left-hand operand of comma expression has no effect How can I stop the warning? 回答1: Use -Wno-unused-value to stop the warning; (the option -Wall includes -Wunused-value ). I think even better is to use another method, like assert(condition && "message"); 回答2: Try: #define assert__(x) for ( ; !(x) ; assert(x) ) use as

Globally suppress c# compiler warnings

你。 提交于 2019-12-28 06:28:49
问题 In my app I have a fair number of entities which have fields which are getting their values set via reflection. (In this case NHibernate is setting them). I'd like to get rid of the "x is never assigned to and will always have its default value 0" warnings, so I can more easily pick out the other warnings. I realize you can surround them in pragma directives, but AFAIK you have to do this for each one. Is there a project wide or solution wide way I could do this? 回答1: Use the C# commandline

Initialise string function result?

元气小坏坏 提交于 2019-12-28 03:40:07
问题 I've just been debugging a problem with a function that returns a string that has got me worried. I've always assumed that the implicit Result variable for functions that return a string would be empty at the start of the function call, but the following (simplified) code produced an unexpected result: function TMyObject.GenerateInfo: string; procedure AppendInfo(const AppendStr: string); begin if(Result > '') then Result := Result + #13; Result := Result + AppendStr; end; begin if(ACondition

Is using #pragma warning push/pop the right way to temporarily alter warning level?

最后都变了- 提交于 2019-12-27 16:48:08
问题 Once in a while it's difficult to write C++ code that wouldn't emit warnings at all. Having warnings enabled is however a good idea. So it is often necessary to disable warnings around some specific construct and have them enables in all other pieces of code. I've seen two ways of doing that so far. The first one is to use #pragma warning( push ) and #pragma warning( pop ) : #pragma warning( push ) #pragma warning( disable: ThatWarning ) //code with ThatWarning here #pragma warning( pop ) The

Visual Studio warning C4334 on assignment but not on initialization

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 17:43:48
问题 Why i got warning on this code: #include <cstdint> int main() { int i = 1; int64_t i64; i64 = 1 << i; } warning C4334: '<<' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) but not on this: #include <cstdint> int main() { int i = 1; int64_t i64 = 1 << i; } ? Tested on vs2013/2015. 回答1: I see the same discrepancy with vs2012. I don't think that there is a good reason for it - hopefully the warning will be emitted in both cases in a newer version of Visual C

How do warnings on undefined selectors work in Objective C?

一世执手 提交于 2019-12-24 16:12:37
问题 Is there any way to make the compiler raise a warning when calling a selector that is not defined ? For example, I have this call somewhere : methodcall time1:[[self.H1time copy] stringValue] stringValue method does not exist anymore in the H1time class and the compiler did not raise anything. copyWithZone is declared as - (NSHour*)copyWithZone:(NSZone *)zone; The compiler raises a warning inside NSHour if I call [self stringValue] . but not in methodcall time1:[[self.H1time copy] stringValue