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.
Related
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
I'm working on a C++ project (VS 2010) using CPLEX.
I have included the required cplex libraries in the project settings as follows:
added the "additional include directories" under C/C++ > general
added the "additional library directories" under linker > general
added the .lib files as "additional dependecies" under linker > input
Everything compiles fine, however my problem is that intellisense still reports errors (red squiggly underlines) such as "cannot open source file" in the #include line, and "identifier undefined" when using variable types defined in the CPLEX library.
The only difference with other projects that don't have this behaviour is that this time I have used windows environment variables in setting the include path, i.e. the library directories and include directories are defined similar to: %CPLEX_STUDIO_DIR%\cplex\include
I have set it like this so that I can build this project on different machines without messing around in the project properties. Since CPLEX is installed separately, using relative paths to specify additional directories is not really an option.
I'd like to repeat that the project compiles, it's only the intellisense errors that are bothering me.
I know I can turn off the intellisense error reporting, but if someone has a workaround for this I'd love to hear about it.
Kind regards,
This problem is known to Microsoft:
http://connect.microsoft.com/VisualStudio/feedback/details/779874/intellisense-cant-handle-using-environemt-variable-in-include-path
The only way I know of to avoid it is to manually enter the full literal path. The bug is marked "deferred" which I think means Microsoft has regarded it not serious enough to be fixed soon.
The solution is to replace %CPLEX_STUDIO_DIR%\cplex\include with $(CPLEX_STUDIO_DIR)\cplex\include. This is the syntax Visual Studio uses for its built-in variables such as $(VCInstallDir), but it also works for environment variables (so long as they don't have the same name as a built-in variable) and is recognised by intellisense as well as the compiler.
(I realise this is an old question, but it ranks highly in search results so it could help others even if not the original poster.)
I have a third party project in my Xcode workspace (it's a dependency for my main project) and I want Xcode to ignore all build warnings from that third party project.
Preferably I'd like to ignore all build warnings for the Vendor/* group in my project since that's where I put all my third party code.
Possible?
Yes, it's possible, but only if you compile the third-party files in a separate target. This way, you can set different compiler flags.
Let's say your main target is an application. You defined your build settings, as well as the compiler warning flags.
Now you want to use some third-party sources. You import them into your project, but they generate warning. You could of course change your main target's settings, but I'm pretty sure you want to keep your own settings.
Simply create an additional target in your project, which is a static library.
Removes the third-party files from your main target, and add them to the library.
In your main target's build phases, link your application with the static library.
This way, you'll be able to use the third-party code in your application, while having different compiler settings for third-party code.
It is possible on a per file basis, see the blog entry at http://blog.bluelightninglabs.com/2011/12/suppressing-xcode-warnings-on-a-per-file-basis/
To summarize: Use the compiler flags on the “Build phases” tab.
Go to Build Phases > Compile Sources. Optionally filter the list. Select the ones you want to exclude and then double click in the blank area under the Compiler Flags column. Add -w and hit return:
if you are worried only about warning via inclusion, then you can wrap your include statements in this:
#pragma clang diagnostic push
// in reality, you will likely need to disable *more* than Wmultichar
#pragma clang diagnostic ignored "-Wmultichar"
#include <TheirLibrary/include.h>
#pragma clang diagnostic pop
if you also want to disable the build warnings it generates, then you can use -w or GCC_WARN_INHIBIT_ALL_WARNINGS = YES for the third party target which you link to or bundle.
ideally, you will file reports with the vendor if it is closed. if it is open, then maybe you should just patch it yourself.
I compile my Xcode projects with very high warnings settings. Sometimes, I have to use third-party frameworks that are distributed as source (rather than as a framework). These frameworks often throw a lot of warnings.
Is there a way to turn off warnings for these folders? I want the stricter level for my own code, but don't care if third-party code violates my warnings level.
Basically, I don't want to see 67 warnings every time I build.
You're looking for this:
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
Flags can be found here: http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Warning-Options.html
Just replace the -W... with whatever you want to ignore.
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