compiler-warnings

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

懵懂的女人 提交于 2019-12-05 03:01:55
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’ 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 idiomatic to do this initialization would be as follows: std::array<int, 10> arr = {}; Although this still

BOOST_STATIC_WARNING

こ雲淡風輕ζ 提交于 2019-12-05 02:09:00
问题 I've recently had some trouble with C++'s implicit casting, so I'm looking for a way to warn people if somebody attempts to assign an int32_t to a uint64_t or whatever. BOOST_STATIC_ASSERT would work wonders for this, except that the code base I'm working with is quite large and relies on a lot of implicit casting, so immediately breaking everything with assertions is unrealistic. It looks like BOOST_STATIC_WARNING would be ideal for me, however, I cannot get it to actually emit a warning.

How to read data into a time_t variable using scanf()?

自闭症网瘾萝莉.ら 提交于 2019-12-05 00:37:07
问题 This code gives me warnings: $ cat test.c #include<stdio.h> #include<time.h> int main() { time_t t; scanf("%lld", &t); printf("%lld\n", t); return 0; } $ gcc test.c -o test test.c: In function ‘main’: test.c:7: warning: format ‘%lld’ expects type ‘long long int *’, but argument 2 has type ‘time_t *’ test.c:8: warning: format ‘%lld’ expects type ‘long long int’, but argument 2 has type ‘time_t’ $ Apart from the warnings, the code works as expected. What should I do to not get the warnings on

c++ warning: enumeration value not handled in switch [-Wswitch]

落爺英雄遲暮 提交于 2019-12-05 00:13:47
I am trying to compile following code without warnings: while (window.pollEvent(event)) { switch (event.type) { case sf::Event::Closed: window.close(); break; case sf::Event::KeyPressed: if(event.key.code == sf::Keyboard::Escape ) window.close(); if( sf::Keyboard::isKeyPressed( sf::Keyboard::Space ) ) particleSystem.fuel( 200/* * window.getFrameTime() */); if( sf::Keyboard::isKeyPressed( sf::Keyboard::A ) ) particleSystem.setPosition( --xpos, ypos ); if( sf::Keyboard::isKeyPressed( sf::Keyboard::D ) ) particleSystem.setPosition( ++xpos, ypos ); if( sf::Keyboard::isKeyPressed( sf::Keyboard::W )

“Consider app.config remapping of assembly …” warning in F#

一曲冷凌霜 提交于 2019-12-04 23:51:11
After I installed VS11, I started to get the following error: Consider app.config remapping of assembly "FSharp.Core, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "2.0.0.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\2.0\Runtime\v2.0\FSharp.Core.dll] to Version "4.0.0.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\2.0\Runtime\v4.0\FSharp.Core.dll] to solve conflict and get rid of warning. C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1490,5): warning MSB3247: Found conflicts between different versions of the same

How can I disable Haskell warning in small block?

心不动则不痛 提交于 2019-12-04 23:50:44
I want to disable warning only some block of code. I searched Google but only find file scope or global scope disable method. Using cabal file or pragma {-# OPTIONS_GHC #-} Can I disable warning for specific function? No, you can't currently in GHC 8.8.1 The {-# OPTIONS_GHC #-} pragma is file-header only and applies to the whole module. And there are no such pragmas (or other ways) to suppress warnings in specific locations. You can check the full list of pragmas in the Haskell user guide: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#pragmas The list of

How do I dump gcc warnings into a structured format?

喜欢而已 提交于 2019-12-04 18:04:00
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 afterwards becomes burdensome. It's equally undesirable to maintain compiler pragmas and push/pop warnings

Visual Studio 2010 (C++): suppress C4706 warning temporarily

こ雲淡風輕ζ 提交于 2019-12-04 17:15:16
问题 When you compile the following C++ source file in Visual Studio 2010 with warning level /W4 enabled #include <cstdio> // for printf #include <cstring> // for strcmp char str0[] = "Hello"; char str1[] = "World"; int main() { int result; if (result = strcmp(str0, str1)) // line 11 { printf("Strings are different\n"); } } you get the following warning warning C4706: assignment within conditional expression for line 11. I want to suppress this warning exactly at this place. So I tried Google and

Warning: Presenting view controllers on detached view controllers is discouraged

依然范特西╮ 提交于 2019-12-04 13:59:37
My situation with this is different than every other example I have been able to find on here. I have a tab based app. On one of the tabs a user is able to press a button that downloads several files from a web server all at once. I make use of NSOperation to perform each of these downloads so that I can utilize the built in dependencies. The downloads are all occurring on a background thread so the app remains responsive. When the final download is complete I put an alertController on screen letting the user know that they are complete. If the user has selected a different tab when the alert

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

南笙酒味 提交于 2019-12-04 12:32:16
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:(NSString *)format; @end @implementation NSString (NSStringPerso) + (NSString*) myStringWithFormat:(NSString