compiler-warnings

Assignment <pointer to array of constants> = <pointer to array>: incompatible pointers

孤者浪人 提交于 2019-11-30 23:54:31
问题 When I compile something like this double da[ 3 ] = { 2., 3., 4. }; double (* pda)[ 3 ] = &da; double const (* cpda)[ 3 ] = pda; // gcc: warning; MSVC: ok gcc warns me warning: initialization from incompatible pointer type [enabled by default] Question: What's the problem with this assignment? Yes, technically, these are different types, but I don't see any danger here, double const (*)[ 3 ] looks even safer for me than double (*)[ 3 ] . I did some tests and results confuse me even more: 1)

Treat *some* warnings as errors in Swift?

一个人想着一个人 提交于 2019-11-30 23:20:29
问题 Imagine I mark the following method deprecated in Swift: @available(*, deprecated=1.0) func myFunc() { // ... } And I treat warnings as errors in Swift by setting OTHER_SWIFT_FLAGS="-warnings-as-errors" . How do I make it show these deprecation notices as warnings, while still treating the rest of the warnings as errors? It seems like GCC had a pretty good solution to this problem: -Werror // treat all warnings as errors -Wno-error=<warning> // don't treat <warning> as error (e.g. -Wno-error

Gradle - compileJava - remove compile Warnings

瘦欲@ 提交于 2019-11-30 23:00:59
问题 We use Gradle 2.1 and java plugin. During compileJava different warnings occur, for example: warning: [options] bootstrap class path not set in conjunction with -source 1.7 Note: ../SomeClass.java uses or overrides a deprecated API. We know what they mean but won't fix them (don't ask, other thread :) Is there a way to avoid these messages somehow? They disturb the output a lot: :project1:compileJava warning: [options] bootstrap class path not set in conjunction with -source 1.7 Note:

Is there a way to show ALL the compiler warnings in Visual Studio 2010?

孤者浪人 提交于 2019-11-30 22:31:10
问题 I'm cleaning up a project to get rid of all the warnings, but I can only see the first 100 or so in the Error List pane. This is a problem because we're using Team Server for source control and all the warnings shown are in files that are currently checked out (and therefore I can't modify without making someone else possibly do a lot of work when they check in). I'd like to be able to see the full list so I can continue my cleaning while others are working. In case it makes a difference, The

How do I quiet the C compiler about a function pointer takes any number of arguments?

心已入冬 提交于 2019-11-30 21:47:47
I have a function pointer inside a struct that gets dynamically set at runtime to the address of another function in various places in my code. It is defined in my header file like this: void *(*run)(); During compile time, I get the following warning about this: warning: function declaration isn't a prototype This warning is benign, because the pointer is used in many places in my code to call the function it points to, and everything works just fine. However, I would really like to silence the warning. If I change it to this: void *(*run)(void); I get compile errors whever I use it, because

gcc options: warning on non-void functions without a return statement

吃可爱长大的小学妹 提交于 2019-11-30 21:32:21
Does anyone know a gcc/g++ option that generates an error/warning if there's a function that has a non-void return value but doesn't contain a return statement in its definition? e.g.: int add(int a, int b) { a+b; } Many thanks in advance! -Wreturn-type . It's enabled by -Wall (which you should always be running with, along with -Werror -Wextra ). 来源: https://stackoverflow.com/questions/9924570/gcc-options-warning-on-non-void-functions-without-a-return-statement

Why do I get “warning: missing initializer for member”? [-Wmissing-field-initializers]

无人久伴 提交于 2019-11-30 20:27:26
I'm wondering why I am getting an warning about initialization in one case, but not the other. The code is in a C++ source file, and using GCC 4.7 with -std=c++11 . struct sigaction old_handler, new_handler; The above produces NO warnings with -Wall and -Wextra . struct sigaction old_handler={}, new_handler={}; struct sigaction old_handler={0}, new_handler={0}; The above produces warnings: warning: missing initializer for member ‘sigaction::__sigaction_handler’ [-Wmissing-field-initializers] warning: missing initializer for member ‘sigaction::sa_mask’ [-Wmissing-field-initializers] warning:

Capturing a variable in a Block when the Block is in the initializer

半腔热情 提交于 2019-11-30 20:22:18
Consider this: id observer = [[NSNotificationCenter defaultCenter] addObserverForName:MyNotification object:nil queue:nil usingBlock:^(NSNotification *note) { [[NSNotificationCenter defaultCenter] removeObserver:observer name:MyNotification object:nil ]; // do other stuff here... } ]; I'm using this pattern to observe a notification once and then stop observing it. But LLVM tells me (under ARC) that Variable 'observer' is uninitialized when captured by block. How can I fix this, since the block necessarily captures the variable before initialization, it being part of the initializer? Will

Treat Warnings as Errors has no effect

╄→尐↘猪︶ㄣ 提交于 2019-11-30 20:02:49
In my project's settings in Visual Studio, I have set 'Treat warnings as errors' to 'All'. The Warning level is set to 4. I tested this by deliberately introducing code that violates CA1305, but it builds (and rebuilds) successfully, returning a Warning. What I expected was that the build would fail and an Error would be returned. Is my understanding wrong? Code Analysis uses a different mechanism to treat warnings as errors. To have Code Analysis warnings treated as such, add a new Code Analysis Ruleset to your solution. To do so, rightclick your solution and choose "Add new item...". Search

Function overloading in C using GCC - compiler warnings

拟墨画扇 提交于 2019-11-30 19:18:57
I am attempting to implement function overloading in C , and I am very close. I am using C99 so the _Generic keyword introduced in C11 is not available to me. I have developed some working code, but when I compile it I get a couple warnings. Working example: #include <stdio.h> #define print(x) \ __builtin_choose_expr(__builtin_types_compatible_p(typeof(x), int ), print_int(x) , \ __builtin_choose_expr(__builtin_types_compatible_p(typeof(x), char[]), print_string(x), \ (void)0)) void print_int(int i) { printf("int: %d\n", i); } void print_string(char* s) { printf("char*: %s\n", s); } int main