compiler-warnings

mixed declarations and codes

自作多情 提交于 2019-12-19 05:47:11
问题 When I compile function with "gcc -o dene -Wall -ansi -pedantic-errors dene.c" ,gcc emits no error.(can you look a line which starts with char ....,in if loop,) static void remove_negation(char *s,char *s1) { char **cmainp=malloc(sizeof(char*)*1); int len=0;int d=0; int i=0; cmainp[0]=malloc(sizeof(char)*300); len=strlen(s); for(i=0;i<len;++i) { if(s[i]=='-') if(i==0 || s[i-1]==',') /*look*/ {char *p=malloc(sizeof(char)*3); /*look*/ ++i; p[0]=s[i]; p[1]='\0'; strcat(s1,","); strcat(s1,p);

mixed declarations and codes

瘦欲@ 提交于 2019-12-19 05:46:15
问题 When I compile function with "gcc -o dene -Wall -ansi -pedantic-errors dene.c" ,gcc emits no error.(can you look a line which starts with char ....,in if loop,) static void remove_negation(char *s,char *s1) { char **cmainp=malloc(sizeof(char*)*1); int len=0;int d=0; int i=0; cmainp[0]=malloc(sizeof(char)*300); len=strlen(s); for(i=0;i<len;++i) { if(s[i]=='-') if(i==0 || s[i-1]==',') /*look*/ {char *p=malloc(sizeof(char)*3); /*look*/ ++i; p[0]=s[i]; p[1]='\0'; strcat(s1,","); strcat(s1,p);

Can I force a compiler error if certain functions are called?

六眼飞鱼酱① 提交于 2019-12-19 05:17:26
问题 I have v1 and v2 versions of my software. v1 uses the registry to save settings, with lots of calls to GetProfileInt, etc. v2 now uses an sqlite db to save settings. We are currently developing both branches and are merging new features from v1 to the v2 branch. We currently have to remember to update any registry calls to use the new config db and this has been missed a few times. What I would like is to throw a compiler error if any of the GetProfile... or WriteProfile... functions are used

Wrong compiler warning when comparing struct to null

喜你入骨 提交于 2019-12-18 19:27:29
问题 Consider the following code: DateTime t = DateTime.Today; bool isGreater = t > null; With Visual Studio 2010 (C# 4, .NET 4.0), I get the following warning: warning CS0458: The result of the expression is always 'null' of type 'bool?' This is incorrect; the result is always false (of type bool ): Now, the struct DateTime overloads the > (greater than) operator. Any non-nullable struct (like DateTime) is implicitly convertible to the corresponding Nullable<> type. The above expression is

Visual Studio 2015 - Compiler Warning (level 2) C4146

微笑、不失礼 提交于 2019-12-18 16:32:16
问题 I have the following line in my code signed int test_case= -2147483648; which generates the error: C4146 unary minus operator applied to unsigned type, result still unsigned but this is still with the data range of teh signed integer type: __int32 signed, signed int, int –2,147,483,648 to 2,147,483,647 The strange things is assigning it as signed long gives this same error, i.e. signed long test_case= -2147483648; The changes below compile OK: signed int test_case= -2147483647; signed int

warning C4003: not enough actual parameters for macro 'max' - Visual Studio 2010 C++

泄露秘密 提交于 2019-12-18 13:53:07
问题 I have the following warnings while compiling an openFrameworks 007 project on Visual Studio 2010 SP1: d:\pedro\development\videoflow\openframeworks\libs\openframeworks\types\ofcolor.h(127): warning C4003: not enough actual parameters for macro 'max' d:\pedro\development\videoflow\openframeworks\libs\openframeworks\types\ofcolor.h(128): warning C4003: not enough actual parameters for macro 'max' d:\pedro\development\videoflow\openframeworks\libs\openframeworks\graphics\ofpixels.h(150):

warning: implicit declaration of function ‘getresuid’ (and ‘seteuid’)

老子叫甜甜 提交于 2019-12-18 05:16:07
问题 I would like to get rid of the warnings. When I compile the source code with gcc -Wall -ansi -o test test.c I get back test.c: In function ‘main’: test.c:12: warning: implicit declaration of function ‘getresuid’ test.c:14: warning: implicit declaration of function ‘seteuid’ When I compile it without -ansi switch gcc -Wall -o test test.c I see on the terminal test.c: In function ‘main’: test.c:12: warning: implicit declaration of function ‘getresuid’ I would like to use -ansi switch and get

Why the compiler does not issue a warning when an object std::vector is declared but never used? [duplicate]

人盡茶涼 提交于 2019-12-18 03:55:23
问题 This question already has answers here : A variable not detected as not used (3 answers) Closed 3 years ago . #include <vector> class Object { }; int main() { Object myObject; std::vector<int> myVector; } Compiler emits: warning: unused variable 'myObject' [-Wunused-variable] No warning for myVector . Why? Is there any way to enable this? 回答1: Whether declaring (and thus initialising and at some point destructung) an arbitrary object has visible side effects cannot be determined in general.

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

大城市里の小女人 提交于 2019-12-17 21:29:19
问题 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 ? 回答1: Use this code : cell. img!.sd_setImage(with: url! as URL, completed: block_image) Suggestion: use URL instead of NSURL let url = URL(string

Is there a rustc equivalent of -Wall -Werror?

泪湿孤枕 提交于 2019-12-17 20:45:44
问题 First 10 minutes learning rust, I'm given 58 lint options and I'm thinking: gcc has a solution to this. To be clear: I want to enabled all warnings/lints ( -Wall ) and treat all warnings as hard errors ( -Werror ). Something that would go in the .toml file? A workaround? 回答1: gcc’s -Werror becomes rustc --deny warnings or the crate attribute #![deny(warnings)] . You can also pass the flag through an environment variable: RUSTFLAGS="--deny warnings" . -Wall or -Weverything aren’t really