Silencing "Documentation issue" warnings in Xcode? - xcode

E.g.
'#param' command used in a comment that is not attached to a function declaration
This warning is valid, however, I am compiling 3rd party code and wish to not have to alter the original source.
I am running Xcode 8.2.1.

I was able to suppress these warnings by going to
Project -> Build Settings -> Apple LLVM 8.1 - Warnings - All Languages, and switching the "Documentation Comments" to No.
(To find the setting, I typed "Documentation" into the search box under Build Settings.)

This solved it for me, surpassing the warnings only in the third party library headers. Just wrap the problematic header #includes with these pragmas:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdocumentation"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#pragma clang diagnostic pop
this is a combination of a hint from
Konchog and Vladimir Grigorov’s super helpful answer here.

Related

How can I suppress compiler warnings in Xcode 5 caused by a 3rd party framework?

I have a 3rd party framework that I have imported into my project, and it is causing compiler warnings to show up from issues in its header files. I do not want to have to change the 3rd party code, as it will likely change in the near future. I found this post:
Disable warnings in Xcode from frameworks
Which talks about how to turn off warnings on a per-file or per-project basis, but I am not certain how to do this for a framework. This is because the files are technically there but Xcode does not show them in the compiled sources section.
Does anyone know of a way to ignore compiler warnings for an included framework?
We've fixed same problem with a 3rd party framework warnings in header files by including problematic files in our pre-compiled header (.pch) with a proper pragma mark.
i.e.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmismatched-tags"
#pragma GCC diagnostic ignored "-Wreorder"
#import <ComponentKit/CKComponentViewConfiguration.h>
#import <ComponentKit/CKArrayControllerChangeset.h>
#import <ComponentKit/CKComponentDataSource.h>
#import <ComponentKit/CKComponentBoundsAnimation.h>
#pragma GCC diagnostic pop

Disable a specific warning in xcode's live-checking only

XCode's live issue tracking is great, most of the time. But there are a few warnings it complains about that get annoying when I'm still in the middle of writing. For instance, unused variables:
I know it's unused, I just finished that line and haven't gotten to the code that uses it yet.
I am fairly anal about compiling without warnings (on -Wall -Wextra -pedantic, minus a couple particular ones), so seeing them when I haven't yet had the chance to address them is a bit irritating. However, I do like most of the live-build warnings and once I actually build, I do want to see these.
So, is there any way to disable certain warnings on the live-issue checking only, keeping them on actual builds? I would be willing to use release settings for live-issue and debug for manual builds if that is possible.
A potential workaround I would also accept is delaying the live checking to only run after 10-15 seconds of inactivity.
Usually i used to do the following to avoid the "unused variable".
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable"
NSArray *ary = [[NSArray alloc] init];
//your code area
#pragma clang diagnostic pop
So the real time waring for "unused variable" is off on the section. and when i need to enable this i just commented out the "#pragma".
Reference
using a #pragma to disable the warning will affect live-preview / compilation time... I dont think there is such a way in xcode. :(

Is there any way to disable all warnings with a pragma in clang or gcc?

GCC and clang let you compile with -w to disable all warnings, but I can't see a #pragma equivalent of it. I can see only pragma support for disabling individual files.
I need this because I have code that I want to compile with high warning levels but which necessarily compiles third party code which generates arbitrary warnings.
You can kind of do it with GCC, almost, using #pragma GCC diagnostic ignored, but unluckily not very well, see here.
The problem is that you cannot just "disable all", you have to disable each single one. Plus, for some warnings it doesn't work (and the docs don't tell you which ones...).
My guess is that this somewhat preliminary and will (hopefully) be improved in the next version.

How to suppress all warnings from non-solution files in VisualStudio

I wonder, whether it is possible to suppress warnings coming from included library files, while showing all solution-file warnings in Visual Studio?
I have a solution that uses stingray library. When I build the solution I keep getting numerous warnings from stingray files, so I am loosing warnings from my files (that are actually in solution and that I own and edit). For me there is no value in included warnings, since I cannot edit those files, but I do need to see all my warnings.
Is there any way I could do it?
Added after first answer:
Sorry for being not clear - I am not building third party library - I am linking the libraries they provided, but I am including their headers in my own - as a results I have numerous warnings in "file included from..." - is there any way to sort that out?
--
Thanks in advance
#pragma warning(push ,3)
# include third-party h-files
#pragma warning(pop)
Another way:
#pragma warning(disable: 4507 4510)
# include third-party h-files
#pragma warning(default: 4507 4510)
Open your third party library's project properties, you can minimize your warning level in build tab.

-isystem for MS Visual Studio C++ Compiler

I usually like to have a lot of warnings enabled when programming. However, some libraries contains code that easily causes warnings (.., python, Qt, ..). When compiling with gcc I can just use -isystem instead of -I to silence that. How can I do the same with the MS compiler? I know of the warning #pragma, but I would like a solution that does not involve compiler specific code all over the place. I also know that I can turn off specific warnings, but that is not what I want either.
BTW: isystem should be a tag of this question, but I was not allowed to do that..
SUMMARY: I want to see all warnings from my code, and no warnings from external code.
As of 2017-08-17 this still seems impossible.
I added a feature request here:
https://developercommunity.visualstudio.com/content/problem/96411/impossible-to-ignore-warnings-from-system-librarie.html
Update 2018:
The issue is now closed as fixed and is available in the standard MS VS installation [source].
A blog post from the MS team goes through the new features [here].
The solution from MS is flexible. You can not only differentiate using paths like you do with --isystem, but for example also by whether you use #include "" or #include <>. The blog post is worth a read to see all the various customization points.
This now exists under /experimental:external /external:I system_include_path /external:W0. See https://blogs.msdn.microsoft.com/vcblog/2017/12/13/broken-warnings-theory/ for many more details.
No clue why MS never picked this up.
We can only try voting on https://visualstudio.uservoice.com/forums/121579-visual-studio-2015/suggestions/14717934-add-a-cl-exe-option-for-system-headers-like-gcc-s
No, MSVC doesn't have an -isystem equivalent.
look at the output output from cl /? :
/wd disable warning n
/we treat warning n as an error
/wo issue warning n once
/w set warning level 1-4 for n
Note that this disables the warnings for your entire project; I remember when using Qt I'd rather change it's main header with the #pragma warning disable and enable at the end again so I could still see all warnings for my own source.
Edit the author edited his question, updated answer: there is no way to get your code with warnings and Qt code without warnings using compiler flags: how are you going to tell the compiler what is 'your' code?
Note that the above flags can be applied at file level as well, so this would allow you to disable the warnings for only those files in which you include Qt headers, but that still means you cannot see them for your own code in that files.
So I stay with the answer above; it is not quite pretty, but I'm pretty sure it's the only way: use #pragma at the beginning and the end of the Qt header(s). Either change the Qt headers (even more ugly), or choose a less invasive way like this:
//your source/header file
#include "shutuppqt.h"
#include <QString>
#include "enableallwarnings.h"
example "shutuppqt.h"
#ifdef MSVC
#pragma warning ( disable : 4222 ) //or whatever warning Qt emits
#else
//....
#endif
example "enableallwarnings.h"
#ifdef MSVC
#pragma warning ( enable : 4222 ) //or default instead of enable
#else
//....
#endif

Resources