Numerous #1885 warnings when compiling an MFC project under VS-2012

Numerous #1885 warnings when compiling an MFC project under VS-2012

In our MFC projects ICC spams hundreds of warnings:

                warning #1885: #pragma region unclosed at end of file

While narrowing down the cause of this warning I noticed it does not reproduce under VS-2010, I’m  getting it under VS-2012 only. So I guess it has something to do with MFC headers that come with VS-2012.

PS: Intel C++ Composer XE 2013 (Update 1, Update 2 and Update 3).

12 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

>>In our MFC projects ICC spams hundreds of warnings:
>>
>> warning #1885: #pragma region unclosed at end of file
>>
>>While narrowing down the cause of this warning I noticed it does not reproduce under VS-2010, I’m getting it under VS-2012 only.
>>So I guess it has something to do with MFC headers that come with VS-2012

MFC is a very large library and I wonder if you could be more specific? Is there any chance to create a small reproducer based on a default MFC project from a VS Projects Wizard ( MDI, or SDI, or Dialog based )?

Reproducing this is trivial. If needed, I can upload the default project produced, but you can save 76MB of downloads by performing the following steps:

  1. Create a new MFC application in VS 2012 (File>New>Templates>Visual C++>MFC>MFC Application). 
  2. Default name is MFCApplication1. Press OK.
  3. Press Finish in the wizard.
  4. In the solution properties, for Intel compiler, select Use Intel C++.
  5. Build.
  6. warning #1885: #pragma region unclosed at end of file errors appear for each included file.

This behavior does not appear with MFC applications created with Visual Studio 2010 or earlier.

Quote:

Sergey Kostrov wrote:

MFC is a very large library and I wonder if you could be more specific? Is there any chance to create a small reproducer based on a default MFC project from a VS Projects Wizard ( MDI, or SDI, or Dialog based )?

Sure, here's a small test project.

Attachments: 

Thanks, Evgeniy! I'm already looking into this. So, could you post a compilation output ( as much as possible lines! ) before that warning message?

>>In our MFC projects ICC spams hundreds of warnings:
>>
>>warning #1885: #pragma region unclosed at end of file

Here is a completely isolated test case to reproduce that 1885 warning:

#pragma region Region_1
void Test() {}
void Test2() {}
void Test3() {}
// #pragma endregion Region_1

int main( void )
{
return ( int )0;
}

Note: It is the same as on msdn.microsoft.com/en-us/library/b6xkz944(v=vs.80).aspx.

Here is a workaround:

#pragma warning ( disable : 1885 )

and it disables that warning.

Here are two references with a description of #pragma region directive:

[ Intel Docs ]

Intel(R) C++ Compiler User and Reference Guides

Document number: 304968-023US
...
Intel Supported Pragmas
...
region/endregion - specifies a code segment in the Microsoft Visual Studio* 2005
Code Editor that expands and contracts by using the outlining feature

Page 1722

[ Microsoft Docs ]

Web-link: msdn.microsoft.com/en-us/library/b6xkz944(v=vs.80).aspx

#pragma region lets you specify a block of code that you can expand or collapse when using the outlining feature of the Visual Studio Code Editor.

Remarks

#pragma endregion marks the end of a #pragma region block.

A #region block must be terminated with #pragma endregion.

Another thing to look at are Afx-like and windows.h header files:

[ Stdafx.h ]

...
#include
#include // MFC core and standard components
#include // MFC extensions
#ifndef _AFX_NO_OLE_SUPPORT
#include // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

// Windows Header Files:
#include
...

Just comment all of them and verify that the warning 1885 is no longer displayed. Then, start uncommenting these headers one at a time from the last one, that is, from windows.h and re-building the test project. The goal is to find a header that has a mismatched pair of #pragma region directives.

Evgeniy, all of that looks like a problem with MFC headers but I'm still leaving some very small possibility that this is a problem with Intel C++ compiler. I hope that Intel software engineers will investigate.

Quote:

Sergey Kostrov wrote:

Evgeniy, all of that looks like a problem with MFC headers but I'm still leaving some very small possibility that this is a problem with Intel C++ compiler. I hope that Intel software engineers will investigate.

Yeah I agree, it looks like an MFC issue. Though while the real cause could be a Microsoft’s responsibility, Intel engineering team may want to suppress generation of the warning for Windows SDK headers (since numerous unrelated warnings could confuse the user).

>>...since numerous unrelated warnings could confuse the user...

I also don't like some warning messages ( however, I really like /W5 and /Wcheck options of Intel C++ compiler since they provide additional information which could help to improve overall quality of codes ).

The workaround I've mentioned in one of my previous post:

>>Here is a workaround:
>>
>>#pragma warning ( disable : 1885 )
>>
>>and it disables that warning.

should work.

Yeah it works, but it's just a workaround.

#pragma warning is quite useful when you want to suppress warnings for 3rd-party headers or if the compiler treats you as a dummy. Though in my opinion compiler should not generate warnings for standard platform headers (since API/SDK user has nothing to do with its quality). And I believe ICC already does so for the other warnings.

I would guess (aside from the most likely MFC issue) the warning is being generated because of how ICC treats #pragma region/endregion blocks. It looks like ICC tries to find matching #pragma endregion in a whole compilation unit, whereas as an outlining feature #pragma region/endregion block should be limited to a single file (well at least I think it should be, not sure how it correlates to C/C++ standard and extension definition).

Perhaps the #pragma endregion is conditionalized out when compiling with ICC. This would be MFC issue. Meaning you will need to disable/enable 1855 around #include < fromMFC >

Jim Dempsey

 

www.quickthreadprogramming.com

Leave a Comment

Please sign in to add a comment. Not a member? Join today