473,396 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

MSIL from C++ with /clr option but no __gc

Clarification needed please.

If I compile a C++ program with the /clr option inpsection
of the resulting assembly with ILDASM shows MSIL even for
methods in classes for which I have not specified garbage
collection with __gc.

Am I correct in thinking there is really two kinds of
managed (i.e. MSIL) code from C++, that which uses garbage
collection and that which does not?
Nov 17 '05 #1
3 3365
NigelW wrote:
Clarification needed please.

If I compile a C++ program with the /clr option inpsection
of the resulting assembly with ILDASM shows MSIL even for
methods in classes for which I have not specified garbage
collection with __gc.

Am I correct in thinking there is really two kinds of
managed (i.e. MSIL) code from C++, that which uses garbage
collection and that which does not?


No, you are incorrect. Using the /clr option will compile almost all C++
code to MSIL whether the types involved are __gc, __value, or __nogc ( the
default ). There are only a few C++ constructs which will not be compiled to
MSIL and these are outlined in the MC++ language specification, section 24.1
.. Everything else, when /clr is used, is compiled to MSIL whether managed or
unmanaged.
Nov 17 '05 #2
-----Original Message-----
NigelW wrote:
Clarification needed please.

If I compile a C++ program with the /clr option inpsection of the resulting assembly with ILDASM shows MSIL even for methods in classes for which I have not specified garbage collection with __gc.

Am I correct in thinking there is really two kinds of
managed (i.e. MSIL) code from C++, that which uses garbage collection and that which does not?
No, you are incorrect. Using the /clr option will compile

almost all C++code to MSIL whether the types involved are __gc, __value, or __nogc ( thedefault ). There are only a few C++ constructs which will not be compiled toMSIL and these are outlined in the MC++ language specification, section 24.1.. Everything else, when /clr is used, is compiled to MSIL whether managed orunmanaged.
.
Thank you for confirming nearly all C++ gets compiled to

MSIL when the /clr option is used. So I know see MSIL can
be used in managed or unmanaged ways (I was confused
because the documentation always equates unmanaged to
native).

In Section 24.1 of the C++ language spec. it says method
calls through pointers, including to virtual functions
through the vtable, cannot be compiled to MSIL. However,
examination of the MSIL for several methods calling
virtual functions shows that virtual methods can in fact
be used without preventing compilation to MSIL. Can you
shed any light on this discrepancy?

Thank you
Nov 17 '05 #3
an*******@discussions.microsoft.com wrote:
-----Original Message-----
NigelW wrote:
Clarification needed please.

If I compile a C++ program with the /clr option inpsection
of the resulting assembly with ILDASM shows MSIL even for
methods in classes for which I have not specified garbage
collection with __gc.

Am I correct in thinking there is really two kinds of
managed (i.e. MSIL) code from C++, that which uses garbage
collection and that which does not?


No, you are incorrect. Using the /clr option will compile almost all
C++ code to MSIL whether the types involved are __gc, __value, or
__nogc ( the default ). There are only a few C++ constructs which
will not be compiled to MSIL and these are outlined in the MC++
language specification, section 24.1 .. Everything else, when /clr
is used, is compiled to MSIL whether managed or unmanaged.
.
Thank you for confirming nearly all C++ gets compiled to

MSIL when the /clr option is used. So I know see MSIL can
be used in managed or unmanaged ways (I was confused
because the documentation always equates unmanaged to
native).

In Section 24.1 of the C++ language spec. it says method
calls through pointers, including to virtual functions
through the vtable, cannot be compiled to MSIL. However,
examination of the MSIL for several methods calling
virtual functions shows that virtual methods can in fact
be used without preventing compilation to MSIL. Can you
shed any light on this discrepancy?


Virtual methods are compiled to MSIL. It is when you use C++'s ability to
call object methods through method pointers that the compiler can not
compile the function in which you make such a call to MSIL. A C++ method
pointer looks like:

returnType SomeObject.*SomePointer(parameterTypes) =
&SomeObject::SomeMethod;

and is invoked via either:

returnType rt = aSomeObject.*SomePointer(parameters);

or

returnType rt = aPointerToSomeObject->*SomePointer(parameters);

This is what 24.1 is talking about when it says that "method calls through
pointers, including to virtual functions
through the vtable, cannot be compiled to MSIL."
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Raymond Lewallen | last post by:
Is there some article out there that helps in reading MSIL? I've been looking but can't find anything, and I'm probably just looking in the wrong spots for the wrong keywords. I understand mov,...
7
by: Raymond Lewallen | last post by:
Microsoft, Can I make a request for a newsgroup specific to MSIL? I have taken great interest in MSIL and have done a lot of reading into MSIL, and written, compiled and tested with success a...
6
by: TrickyDicky | last post by:
Hi all, I'm just starting to experiment with MSIL but am getting confused about c# and MSIL integration. I understand that c# is compiled into MSIL before it is JIT'ed and then executed. I...
7
by: carl.manaster | last post by:
Hi, I'd like to take a string containing MSIL code, assemble it, execute it, and receive the result all from my running C# application. So far I've managed to manually create some MSIL code...
1
by: TGF | last post by:
Hello, I am calling a Filestream::Read() (i.e. fs->Read(arg1, arg2, arg3)). The problem is I have a pointer to an unsigned char block of memory and would like to fill it with the call to 'Read'....
4
by: James dean | last post by:
My understanding is the MSIL runs on the CLR and the CLR is basically the JIT compiler plus Garbage collection. This part "MSIL runs on the CLR" is a bit vague to me can anyone give me a clearer...
1
by: Bern McCarty | last post by:
I am using MEC++ in VC 7.1. I had a method on a __gc object that looked like this: __property System::UInt32 get_MyProperty(void) { System::Byte __pin * pinBytes = &m_byteArray; // entire...
2
by: microsoft | last post by:
Hi All, I am fairly new to Managed C++ extensions. I started trying to implement a interface defined in a C# project, in C++. The problem was with passing value arrays from c# to c++. I found...
5
by: kchui | last post by:
I have a C# interface as: public interface IBar{ void TestParam(ref StringCollection a, ref int b); } And I need to implment it in Managed C++, and I try to implement it as: public __gc...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.