Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
Announcements
The Intel sign-in experience has changed to support enhanced security controls. If you sign in, click here for more information.
7779 Discussions

Disable remarks/warnings/messages temporarily

David_S_5
Beginner
784 Views

Hi, I'm new to the Intel compiler having previously used Visual Studio C++ compiler. With VS we would use a #pragma to disable various warnings just before including third party headers but then re-enable them after inclusion (there's no way we can fix those warnings and we don't want our output flooded with things we can't change as it makes it harder to see things we are doing wrong ourselves).

I'm looking for a similar way to temporarily disable remarks/warnings/numbered messages around header includes, but leave them enabled for our own code so we can avoid making those mistakes? I've only seen compiler options that disable them for the entire compilation unit.

We find this genuinely useful but if it's not considered good practise I'm happy to hear why.

0 Kudos
3 Replies
Melanie_B_Intel
Employee
784 Views

You can use #pragma warning push/pop to surround the #include to suppress most warnings. There are some warnings that can't be suppressed this way due to compiler scope issues.

#pragma warning push
#pragma warning disable M N P ... // M N P are the warning numbers that you want to suppress
#include <file>
#pragma warning pop

David_S_5
Beginner
784 Views

Ok, thanks, that's similar to VS. Can we do the same with numbered Remark and Message outputs? Again they're probably useful for our code but not for included libraries.

Melanie_B_Intel
Employee
784 Views

Yes it should work for Remarks too. 

Reply