Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

#pragma warning( disable: 46 ) does not disable

bevin_b_
New Contributor I
1,031 Views

Compiling using Parallel Studio 2017 on Windows 10, VS 2015 community edition

 

#ifdef WIN32
#pragma warning( push,    46 )
#pragma warning( disable: 46 )
#define _Pragma(text) __pragma(text)    // ignore this warning message
#pragma warning( pop )
#endif

 

1>..\..\src\./checker.h(294): warning #46: "_Pragma" is predefined; attempted redefinition ignored
1>    #define _Pragma(text) __pragma(text)
1>            ^


Why did the warning #46 not get suppressed?

 

0 Kudos
2 Replies
Michael_R_Intel5
Employee
1,031 Views

In the Intel Compiler #pragma warning is implemented so it is applied at the point of the next statement or declaration.  In your example there is no such declaration or statement until after the diagnostic is generated.

To workaround the problem you can add a dummy declaration after the #pragma warning like so:

#pragma warning( push,    46 )
#pragma warning( disable: 46 )
int dummy();
#define _Pragma(text) __pragma(text)    // ignore this warning message
#pragma warning( pop )

 

 

0 Kudos
bevin_b_
New Contributor I
1,031 Views

I assume this is seen as a bug and is going to get fixed!

 

 

0 Kudos
Reply