compiler-warnings

Where do I change the setting in Eclipse so that it would generate serialVersionUID for Serializable classes?

孤街浪徒 提交于 2019-12-01 22:54:07
I want Eclipse to generate a serialVersionUID for classes that implement Serializable . However, my Eclipse instance does not throw me a warning or an error when I create a class that implements Serializable . Also, it does not give an suggestion about adding a generated serialVersionUID . Where do I change the required setting? To turn on warning for Serializable class without a serialVersionID, go to Window > Preference > Java > Compiler > Errors/Warnings and search for Serializable class without a serialVersionID . Set that to Error or Warning based on your preference. Once warning for "

User defined compiler warning or error in C# [duplicate]

孤人 提交于 2019-12-01 21:27:04
This question already has an answer here: Custom Compiler Warnings 10 answers Is it possible to have some code let the compiler generate a compile warning or error? Maybe with Attributes? ** Having the first answer and a few comments I realize my question is not as a clear as I expected and wanted it to be. I apologize. Hopefully all contributers are still with us. ** So I am more looking towards an internal DSL. S.Th. like [MustAssign] public string Val {get; set;] Do you mean #warning ? #warning lets you generate a level one warning from a specific location in your code. For example:

How to not invoke warning: type specifier missing?

假装没事ソ 提交于 2019-12-01 19:56:29
I am reading " The C programming Language " by Brian W. Kernighan and Dennis M. Ritchie. In chapter 1.2 "Variables and Arithmetic Expressions" they demonstrate a simple Fahrenheit to Celsius converter program. When I compile the program (Terminal.app, macOS Sierra), I get this warning: $ cc FtoC.c -o FtoC.o FtoC.c:5:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int] main() ^ 1 warning generated. This is the C program: FtoC.c: 1 #include <stdio.h> 2 3 /* print Fahrenheit-Celsius table 4 for fahr = 0, 20, ..., 300 */ 5 main() 6 { 7 int fahr, celsius; 8 int lower, upper, step;

How to mark build as unstable when warning trend has arisen?

醉酒当歌 提交于 2019-12-01 17:33:52
So we use Jenkins in conjunction with MS Build to build our projects. We also have a warnings plugin and a large number of warnings in our projects. I am trying to fight with these warnings. One of the steps which I would like to take is to mark build as unstable when number of warnings in the last build is greater than in the previous one. Maybe I should go even further and mark such build as a failure but I guess the mechanizm will be the same for both of marks. An example screenshot: I could not find any info on the web how to do this. I know that some plugins for scanning log files exist,

C++: 'cout << pointer << ++pointer' generates a compiler warning

倾然丶 夕夏残阳落幕 提交于 2019-12-01 16:56:06
I have a C++ learning demo here: char c = 'M'; short s = 10; long l = 1002; char * cptr = &c; short * sptr = &s; long * lptr = &l; cout << "cptr:\t" << static_cast<void*>(cptr) << '\n'; cout << "cptr++:\t" << static_cast<void*>(++cptr) << '\n'; cout << "sptr:\t" << sptr << '\n'; cout << "sptr++:\t" << ++sptr << '\n'; cout << "lptr:\t" << lptr << '\n'; cout << "lptr++:\t" << ++lptr << '\n'; cout << c << '\t' << static_cast<void*>(cptr) << '\t' << static_cast<void*>(++cptr) << '\n'; cout << s << '\t' << sptr << '\t' << ++sptr << '\n'; cout<< l << '\t' << lptr << '\t'<< ++lptr << '\n'; The

‘noreturn’ function does return

有些话、适合烂在心里 提交于 2019-12-01 16:12:13
When I compile the C program below, I get this warning: ‘noreturn’ function does return . This is the function: void hello(void){ int i; i=1; } Why could it be happening? All the call to this function is hello(); EDIT: The full error output: home.c: In function ‘hello’: hhme.c:838:7: error: variable ‘i’ set but not used [-Werror=unused-but-set-variable] home.c:840:1: error: ‘noreturn’ function does return [-Werror] cc1: all warnings being treated as errors make: *** [home.o] Error 1 It is possible to tell gcc that a particular function never returns. This permits certain optimizations and

Are my lambda parameters really shadowing my locals?

筅森魡賤 提交于 2019-12-01 16:03:41
问题 I'm dealing with some C code that takes some data, and forwards it to the function passed in: void foo(int* data, void (*fun)(int*)){ (*fun)(data); }; The following works without warning: void bar(int* data){}; int main(){ int data=0; foo(&data,bar); } However, if I use a lambda instead: int main(){ int data=0; foo(&data,[](auto data){}); } I get the following warning: warning: declaration of ‘data’ shadows a previous local [-Wshadow] foo(&data,[](auto data){}); ^ o.cpp:14:7: note: shadowed

Visual Studio 2013 Compiler Warnings not Showing

。_饼干妹妹 提交于 2019-12-01 11:09:44
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? 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 Rules" by default, which did not even show warning for straight forward things like unused local variables.

Why this warning from IBM XL C/C++ compiler?

不羁岁月 提交于 2019-12-01 04:03:19
Here's a minimum code example that illustrates the problem: #include <iostream> class Thing { // Non-copyable Thing(const Thing&); Thing& operator=(const Thing&); int n_; public: Thing(int n) : n_(n) {} int getValue() const { return n_;} }; void show(const Thing& t) { std::cout << t.getValue() << std::endl; } int main() { show(3); } This yields the same error: int main() { show( Thing(3) ); } IBM XL C/C++ 8.0 compiler under AIX emits these warnings: "testWarning.cpp", line 24.9: 1540-0306 (W) The "private" copy constructor "Thing(const Thing &)" cannot be accessed. "testWarning.cpp", line 24.9

In Haskell, what does it mean if a binding “shadows an existing binding”?

一世执手 提交于 2019-12-01 03:51:01
I'm getting a warning from GHC when I compile: Warning: This binding for 'pats' shadows an existing binding in the definition of 'match_ignore_ancs' Here's the function: match_ignore_ancs (TextPat _ c) (Text t) = c t match_ignore_ancs (TextPat _ _) (Element _ _ _) = False match_ignore_ancs (ElemPat _ _ _) (Text t) = False match_ignore_ancs (ElemPat _ c pats) (Element t avs xs) = c t avs && match_pats pats xs Any idea what this means and how I can fix it? Cheers. It means that you have a symbol pats defined somewhere else in your program or imported from some library module, and it's visible in