compiler-warnings

The assignment to variable has no effect?

Deadly 提交于 2019-12-22 04:40:08
问题 When I do this: count = ++count; Why do i get the warning - The assignment to variable count has no effect ? This means that count is incremented and then assigned to itself or something else ? Is it the same as just ++count ? What happens in count = count++; ? Why don't I get a warning for this ? 回答1: count++ and ++count are both short for count=count+1 . The assignment is built in, so there's no point to assigning it again. The difference between count++ (also knows as postfix ) and ++count

How to address C4191 warning around calls to GetProcAddress with FARPROC?

雨燕双飞 提交于 2019-12-22 04:26:29
问题 Recently I tried to use /Wall Visual C++ option to enable all warnings and found that the following code: typedef BOOL ( WINAPI * TIsWow64ProcessFunction )( HANDLE, BOOL* ); TIsWow64ProcessFunction isWow64ProcessFunction = reinterpret_cast<TIsWow64ProcessFunction> ( ::GetProcAddress( kernel32DllHandle, "IsWow64Process" ) ); spawned C4191: warning C4191: 'reinterpret_cast' : unsafe conversion from 'FARPROC' to 'TIsWow64ProcessFunction' Calling this function through the result pointer may cause

Why can I initialize a regular array from {}, but not a std::array

不羁的心 提交于 2019-12-22 04:09:38
问题 This works: int arr[10] = {}; All elements of arr are value-initialized to zero. Why doesn't this work: std::array<int, 10> arr({}); I get the following warning from g++ (version 4.8.2): warning: missing initializer for member ‘std::array<int, 10ul>::_M_elems’ 回答1: There are two issues one which is a matter of style and the warning. Although it may not be obvious, aggregate initialization is happening on a temporary which is then being used as an argument to the copy constructor. The more

Cocoa - Calling a variadic method from another variadic one (NSString stringWithFormat call)

微笑、不失礼 提交于 2019-12-21 20:48:32
问题 I have a problem with [NSString strigWithFormat:format] because it returns an id, and I have a lot of code where I changed a NSString var to an other personal type. But the compiler does not prevent me that there are places where a NSString is going to be set into another type of object. So I'm writing a category of NSString and I'm goind to replace all my calls to stringWithFormat to myStringWithFormat . The code is : @interface NSString (NSStringPerso) + (NSString*) myStringWithFormat:

How do I dump gcc warnings into a structured format?

倖福魔咒の 提交于 2019-12-21 20:44:52
问题 Like many, I build my project with the an abundance of warning flags. Since not all warning flags are detrimental, the compilation becomes noisy. Warnings such as "unused variables", "shadowing members in initialization lists", "missing switch defaults", are all important to log, but they create too much clutter during builds, and it is hard to spot the important warnings. Given a large project, there can be thousands of warnings mixed in with build statements, and parsing though it

Why do I have warning “C4199 two-phase name lookup is not supported for C++/CLI, C++/CX, or openmp”?

不羁的心 提交于 2019-12-21 18:57:51
问题 I have many templates in my project. Everything is running fine but I've been getting this warning many times for a long time now. Should I keep ignoring it or should I use #pragma warning(disable : 4199) ? 回答1: Ok Thanks to Simon and Raymond's article I was able to solve it. I no more have that warning anywhere in my code. Just added the command as the article describes at it's very bottom. Here's an image of where exactly I added the command for those like me that might have trouble finding

Why do I have warning “C4199 two-phase name lookup is not supported for C++/CLI, C++/CX, or openmp”?

北城以北 提交于 2019-12-21 18:57:30
问题 I have many templates in my project. Everything is running fine but I've been getting this warning many times for a long time now. Should I keep ignoring it or should I use #pragma warning(disable : 4199) ? 回答1: Ok Thanks to Simon and Raymond's article I was able to solve it. I no more have that warning anywhere in my code. Just added the command as the article describes at it's very bottom. Here's an image of where exactly I added the command for those like me that might have trouble finding

How to suppress a specific warning in Swift

一笑奈何 提交于 2019-12-21 12:06:56
问题 I have a Swift function doing something like this: func f() -> Int { switch (__WORDSIZE) { case 32: return 1 case 64: return 2 default: return 0 } } Because __WORDSIZE is a constant, the compiler always gives at least one warning in the switch body. Which lines are actually marked depends on the target I am building for (e.g. iPhone 5 vs. 6; interestingly iPhone 5 gives a warning for the 64-bit case whereas iPhone 6 gives two warnings for 32-bit and default). I found out that the Swift

Why does gcc report “implicit declaration of function ‘round’”?

会有一股神秘感。 提交于 2019-12-21 10:34:18
问题 I have the following C code: #include <math.h> int main(int argc, char ** argv) { double mydouble = 100.0; double whatever = round(mydouble); return (int) whatever; } When I compile this, I get the warnings: round_test.c: In function ‘main’: round_test.c:6: warning: implicit declaration of function ‘round’ round_test.c:6: warning: incompatible implicit declaration of built-in function ‘round’ I'm rusty with C, but I thought that the #include brought a declaration for round() into scope. I've

Why does gcc report “implicit declaration of function ‘round’”?

时光总嘲笑我的痴心妄想 提交于 2019-12-21 10:34:12
问题 I have the following C code: #include <math.h> int main(int argc, char ** argv) { double mydouble = 100.0; double whatever = round(mydouble); return (int) whatever; } When I compile this, I get the warnings: round_test.c: In function ‘main’: round_test.c:6: warning: implicit declaration of function ‘round’ round_test.c:6: warning: incompatible implicit declaration of built-in function ‘round’ I'm rusty with C, but I thought that the #include brought a declaration for round() into scope. I've