Converting Projects from Mixed Mode to Pure Intermediate Language


For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.

All Visual C++ CLR projects link to the C run-time libraries by default. Consequently, these projects are classified as mixed-mode applications, because they combine native code with code that targets the common language runtime (managed code). When they are compiled, they are compiled into intermediate language (IL), also known as Microsoft intermediate language (MSIL).

To convert your mixed-mode application into pure intermediate language

  1. Remove links to the C run-time libraries (CRT):

    1. In the .cpp file defining the entry point of your application, change the entry point to Main(). Using Main() indicates that your project does not link to the CRT.

    2. In Solution Explorer, right-click your project and select Properties on the shortcut menu to open the property pages for your application.

    3. In the Advanced project property page for the Linker, select the Entry Point and then enter Main in this field.

    4. For console applications, in the System project property page for the Linker, select the SubSystem field and change this to Console (/SUBSYSTEM:CONSOLE).

      System_CAPS_ICON_note.jpg Note

      You do not have to set this property for Windows Forms applications because the SubSystem field is set to Windows (/SUBSYSTEM:WINDOWS) by default.

    5. In stdafx.h, comment out all the #include statements. For example, in console applications:

      // #include <iostream>  
      // #include <tchar.h>  


      For example, in Windows Forms applications:

      // #include <stdlib.h>  
      // #include <malloc.h>  
      // #include <memory.h>  
      // #include <tchar.h>  
    6. For Windows Forms applications, in Form1.cpp, comment out the #include statement that references windows.h. For example:

      // #include <windows.h>  
  2. Add the following code to stdafx.h:

    #ifndef __FLTUSED__  
    #define __FLTUSED__  
       extern "C" __declspec(selectany) int _fltused=1;  
  3. Remove all unmanaged types:

    1. Wherever appropriate, replace unmanaged types with references to structures from the System namespace. Common managed types are listed in the following table:

      BooleanRepresents a Boolean value.
      ByteRepresents an 8-bit unsigned integer.
      CharRepresents a Unicode character.
      DateTimeRepresents an instant in time, typically expressed as a date and time of day.
      DecimalRepresents a decimal number.
      DoubleRepresents a double-precision floating-point number.
      GuidRepresents a globally unique identifier (GUID).
      Int16Represents a 16-bit signed integer.
      Int32Represents a 32-bit signed integer.
      Int64Represents a 64-bit signed integer.
      IntPtrA platform-specific type that is used to represent a pointer or a handle.
      SByteRepresents an 8-bit signed integer.
      SingleRepresents a single-precision floating-point number.
      TimeSpanRepresents a time interval.
      UInt16Represents a 16-bit unsigned integer.
      UInt32Represents a 32-bit unsigned integer.
      UInt64Represents a 64-bit unsigned integer.
      UIntPtrA platform-specific type that is used to represent a pointer or a handle.
      VoidIndicates a method that does not return a value; that is, the method has the void return type.