473,398 Members | 2,404 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,398 software developers and data experts.

Mixed mode programming problem in C++/CLI

In Managed C++ in order to share the functionality of a class between
its CLR code and native C++ code, in essence mixed mode programming for
a class, I would design the __gc class so its corresponding __nogc C++
class would be a nested class of the __gc class. The __gc class would
have a pointer to the __nogc C++ class as a private data member. Then
when the __gc class created an object of the native class, it would pass
itself as a pointer to the __nogc C++ class's constructor. The __nogc
class would put this pointer into a corresponding gcroot<>. Then the
__nogc class would be able to access all the members of its
corresponding __gc class via this pointer since, in the 2003 C++ update,
a nested class now has access to all the members of its enclosing class
via a pointer to that class, and VC++ implements that 2003 C++ item.

Now in C++/CLI using this same technique I am told that a ref class can
not have a nested native C++ class.

Oh brother !!!!!

How I am now supposed to access the public, protected, and private
members of a ref class from its corresponding native C++ class using
mixed mode programming in C++/CLI ?

If you tell me that I have to now redesign all my Managed C++ code so
that protected and private data members of my class must now be passed
to a corresponding native C++ class whenever it needs this
functionality, I will not be a happy camper.
Apr 21 '06 #1
1 2148
Edward Diener wrote:
In Managed C++ in order to share the functionality of a class between
its CLR code and native C++ code, in essence mixed mode programming for
a class, I would design the __gc class so its corresponding __nogc C++
class would be a nested class of the __gc class. The __gc class would
have a pointer to the __nogc C++ class as a private data member. Then
when the __gc class created an object of the native class, it would pass
itself as a pointer to the __nogc C++ class's constructor. The __nogc
class would put this pointer into a corresponding gcroot<>. Then the
__nogc class would be able to access all the members of its
corresponding __gc class via this pointer since, in the 2003 C++ update,
a nested class now has access to all the members of its enclosing class
via a pointer to that class, and VC++ implements that 2003 C++ item.

Now in C++/CLI using this same technique I am told that a ref class can
not have a nested native C++ class.

Oh brother !!!!!

How I am now supposed to access the public, protected, and private
members of a ref class from its corresponding native C++ class using
mixed mode programming in C++/CLI ?

If you tell me that I have to now redesign all my Managed C++ code so
that protected and private data members of my class must now be passed
to a corresponding native C++ class whenever it needs this
functionality, I will not be a happy camper.


I can now see that the only solution in C++/CLI is:

1) Make the native C++ class a separate class in the same assembly
2) Change 'protected' members in my ref class which I want
to access from my native C++ class to 'protected public'.
3) Change 'private' members in my ref class which I want
to access from my native C++ class to 'internal'.
Apr 22 '06 #2

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

Similar topics

1
by: Mike Kamzyuk | last post by:
Hello all. Basically, I need to call a mixed-mode dll's function (which uses managed code) from a native or mixed-mode dll function (which does not use managed code). I'm wondering if this could...
0
by: Edward Diener | last post by:
I have some questions about the instructions for creating a mixed mode DLL in the MSDN topic "Converting Managed Extensions for C++ Projects from Pure Intermediate Language to Mixed Mode" in the...
9
by: Edward Diener | last post by:
I received no answers about this the first time I posted, so I will try again. My inability to decipher an MSDN topic may find others who have the same inability and someone who can decipher and...
8
by: Bern McCarty | last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains other than the default AppDomain? Is there any means at all of doing this? Mixed-mode is incredibly convenient, but if I...
8
by: Nadav | last post by:
Hi, I am writing a performence critical application, this require me to stick to unmanaged C++ as performance is much better using unmanaged C++ ( about 33% better ), Still, I am trying to avoid...
4
by: Lonewolf | last post by:
hi, I'm still in the process of transiting from MFC/VC6 to vs2005, and a lot of things are very alien to me. So hope you could bear with me if my question sounds stupid. Basically I have native...
2
by: Doug Belkofer | last post by:
We have created a fairly complex mixed-mode DLL that we want to use from VB.NET. The mixed-mode DLL is written in C++, and does use the standard C runtime libraries. An unusual thing is happening...
8
by: Edward Diener | last post by:
By reuse, I mean a function in an assembly which is called in another assembly. By a mixed-mode function I mean a function whose signature has one or more CLR types and one or more non-CLR...
0
by: emu | last post by:
Hi All, I have an unmanaged C++ application that references a mixed mode image DLL (mixed managed and unmanaged). Under .NET 1.1 we could trust the dll (the mixed mode dll) by running the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.