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).
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:
- Create a new MFC application in VS 2012 (File>New>Templates>Visual C++>MFC>MFC Application).
- Default name is MFCApplication1. Press OK.
- Press Finish in the wizard.
- In the solution properties, for Intel compiler, select Use Intel C++.
- 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.
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).
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 >