473,413 Members | 1,727 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,413 software developers and data experts.

Simple Types and Marshalling Question

Greetings,

When working with managed c++, do you have to do anything special when going
from simple types from managed to unmanaged and vice versa. Or is
marshalling handled automatically for you?
I have seen from several posts that you have to do special conversions for
strings, but what about the other types such as int, long,ect. In my case I
want to save it as a member variable from a managed class into an unmanaged
class's.

(ie:)
// Managed function calls a pointer to a unmanaged class's function.
void TestNum(int newNum)
{
// Call unmanaged class's function.
pMyUnmanagedClass->UpdateNewNum(newNum);
}

void CMyUnmanagedClass::UpdateNewNum(int nNumber)
{
// Do I have to do anything special here????
// Or is this handled through the marshalling?
m_nMemberTest = nNumber;
}
Thanks in advance!


Nov 17 '05 #1
2 1254
BartMan wrote:
Greetings,

When working with managed c++, do you have to do anything special
when going from simple types from managed to unmanaged and vice
versa. Or is marshalling handled automatically for you?
I have seen from several posts that you have to do special
conversions for strings, but what about the other types such as int,
long,ect. In my case I want to save it as a member variable from a
managed class into an unmanaged class's.

(ie:)
// Managed function calls a pointer to a unmanaged class's function.
void TestNum(int newNum)
{
// Call unmanaged class's function.
pMyUnmanagedClass->UpdateNewNum(newNum);
}

void CMyUnmanagedClass::UpdateNewNum(int nNumber)
{
// Do I have to do anything special here????
// Or is this handled through the marshalling?
m_nMemberTest = nNumber;
}


built-in scalar types char, byte, int, short, long, __int64, double, float
(etc) are all mapped directly across and can simply be copied between
managed and unmanaged.

-cd
Nov 17 '05 #2
Thanks! That makes sense.

"Carl Daniel [VC++ MVP]" wrote:
BartMan wrote:
Greetings,

When working with managed c++, do you have to do anything special
when going from simple types from managed to unmanaged and vice
versa. Or is marshalling handled automatically for you?
I have seen from several posts that you have to do special
conversions for strings, but what about the other types such as int,
long,ect. In my case I want to save it as a member variable from a
managed class into an unmanaged class's.

(ie:)
// Managed function calls a pointer to a unmanaged class's function.
void TestNum(int newNum)
{
// Call unmanaged class's function.
pMyUnmanagedClass->UpdateNewNum(newNum);
}

void CMyUnmanagedClass::UpdateNewNum(int nNumber)
{
// Do I have to do anything special here????
// Or is this handled through the marshalling?
m_nMemberTest = nNumber;
}


built-in scalar types char, byte, int, short, long, __int64, double, float
(etc) are all mapped directly across and can simply be copied between
managed and unmanaged.

-cd

Nov 17 '05 #3

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

Similar topics

24
by: Matt Feinstein | last post by:
Hi all-- I'm new to Python, and was somewhat taken aback to discover that the core language lacks some basic numerical types (e.g., single-precision float, short integers). I realize that there...
3
by: PHil Coveney | last post by:
Hello, I am having difficulty marshalling structures when calling DeviceIoControl. I am importing this Win32 function as static extern int DeviceIoControl (int hDevice, int...
2
by: Michael | last post by:
Hi, In VB6 I wrote an application that had to read lots of fixed length disk records from another system. These records were divided up into many fixed length fields. In VB6 the easy solution...
1
by: MuZZy | last post by:
Hello, I am probably facing a sort of language barrier, but i can't really get what 'marshalling' is in terms of .NET Is it a kind of type casting? And when do you use it? Thank you, Andrey
0
by: Paul Cotgrove | last post by:
I am currently in the process of wrapping the SNMP API provided by MS to provide a managed assembly that can be referenced within my C# services for performing SETs, GETs, etc. I have hit a snag...
9
by: WithPit | last post by:
I am trying to create an Managed C++ Wrapper around an unmanaged library which contains C++ code. Some of the unmanaged methods returns an returntype which is of the abstract base type (for...
1
by: John Ye | last post by:
Hello Folks! I have a vendor that has supplied me with a VB6 Module and DLL (and it works in VB6) that I would really like to migrate to VB.Net. I have used the Upgrade Wizard in VS.Net but it...
10
by: Bryce Calhoun | last post by:
Hello, First of all, this is a .NET 1.1 component I'm creating. SUMMARY ----------------------- This component that I'm creating is, for all intents and purposes, a document parser (I'm...
4
by: Beorne | last post by:
I have to call a c++ library funtion with the following signature: void ReadBool(bool* pb1) unsafe static extern void NicamPLCRead(out bool); but this does not work, the bool (not...
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...
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
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,...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.