Simple way to add #using in mixed Cpp?

  • Thread starter Thread starter Jon
  • Start date Start date
J

Jon

I am creating a mix managed/unmanaged C++ project.

Since some of the *.cpp's do not use managed extension,
the project option of [Use managed extensions] has to be set to 'no'.

( Note that using '#pragma unmanaged' in a managed *.cpp file:
1) slows down compilation,
2) and severely pollutes the exported managed namespaces. )

This forces me to manually add #using statements.

I avoided configuration dependent statements like #using "..\debug\ClassLibrary1.dll" by:

1) setting the following project option
[Resolve #using References] = "$(OutDir)"

2) and modifying stdafx.cpp as follows:
//file stdafx.cpp
#using <mscorlib.dll> //add system references here and in the reference folder
#using "ClassLibrary1.dll" //add project references here and in the reference folder
#include "stdafx.h"

Is there a simpler way?
 
Hi Jon,

I was reviewing your post carefully and think the method you used is well
and simple enough.

Meantime, I will consult this issue to the dev team member, if they have
another useful way to do that, I will update soon.


Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
Hi Jon,

I got the response from the product team, they confirm it is the correct
way to do it. in general, however, they would recommend setting the [Force
#using] property (/FU) rather than setting #using in code, when using the
IDE.


Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
Back
Top