question

PeterBoulton-1933 avatar image
0 Votes"
PeterBoulton-1933 asked PeterBoulton-1933 commented

Multi-processor Compilation and #import directive

I've just built a new dev box, which has a 12 core processor. I understand that it's possible to tell the compiler to use multi-processors on the C++/General page.

However, #import is not supported with this option and generates C2813 errors. I've read somewhere that it's possible to have these files compiled with a single processor whilst the remaining files, which don't contain #import, benefit from the multiprocessor compilation.

In the Visual Studio 2019 Property Pages for a C++ project, how do you specify that certain source files (the ones that contain #import...) are compiled with /MP1 while everything else is compiled with /MP?

Or can this only be achieved outside of the GUI (and please excuse my ignorance)... how?

TIA

Pete

c++vs-msbuild
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

DavidLowndes-6766 avatar image
0 Votes"
DavidLowndes-6766 answered PeterBoulton-1933 commented

Try selecting the individual file(s) that have #import in Solution Explorer and changing the /MP option for just those files.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Ah thank you! I have a feeling I rather missed the obvious there. :-( Appreciate the response.

Now, unfortunately, I find that nearly all the source files in my rather large project #include or depend on files that ultimately contain #import, and therefore need to be exceptions! Back to single core compiles! In my solution, the issue traces back to:

 #import "C:\program files\common files\system\ado\msadox.dll"
    
 #ifdef _WIN64
     #import "C:\program files\common files\system\ado\msado15.dll" rename("EOF","EndOfFile")
 #else
     #include "msado15.tlh"
 #endif
 // #import "C:\Program Files\Common Files\System\ado\msjro.dll"   no_namespace
    
 #pragma warning (default: 4146)

I'm not sure whether there is a solution that would work round this issue for me.

Many thanks again!


0 Votes 0 ·

I can't think of any magic bullet Peter. Presumably you'd have to re-arrange your code to minimize that dependency as much as possible. Whether you'd see any significant gain over the time taken to do so, is questionable.

1 Vote 1 ·

Hi David,

Many thanks for responding (again) so quickly and helpfully.

When I was compiling with /MP and was getting all the C2813 errors I would certainly say the Output window was flowing through much faster than without the /MP option, although that may have been because compilation stops when it hits C2813, and there were a lot of them!

It's a shame - I have built a lovely new machine with a Ryzen 5900X with 12 cores/25 virtual and all I can use is one of the cores! Maybe in the future.... :-)

Thanks again!

Pete

0 Votes 0 ·