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

struct output parameter

In a Managed C++ module, I have a function returning an integer as
output parameter:

bool Func1( [System::Runtime::InteropServices::Out] int __gc *iout)
{
*iout = 33;
return true;
}

Calling Func1 from a C# application works correctly:

int iValue;
Func1(out iValue); // iValue correctly returned as 33

However, if using s struct parameter, I don't get the data returned

MC++:

__value struct MyStruct
{
public __value double dVal1;
public __value double dVal2;
};

MyStruct m_data; // membe var

bool Func2( [System::Runtime::InteropServices::Out] MyStruct __gc *pOut)
{
m_data.dVal1 = 11;
m_data.dVal2 = 22;

*pOut = m_data; // does not work - crashes application

pOut = &m_data; // Function call succeedes, but m_data does not
arrive in C# app
return true;
}

C#:

MyStruct data = new MyStruct ();
Func2(out data); // data is empty

How do I pass a struct output parameter correctly from MC++ to C# ???
Any help is appreciated
Regards Urs

Nov 15 '05 #1
1 3177
It looks to me like the problem is on the C++ side. Have you tried the
languages.vc newsgroup?

--
Eric Gunnerson

Visit the C# product team at http://www.csharp.net
Eric's blog is at http://blogs.gotdotnet.com/ericgu/

This posting is provided "AS IS" with no warranties, and confers no rights.
"Urs Wigger" <ns_urs.wigger@leica-geosystems_ns.com> wrote in message
news:eg*************@TK2MSFTNGP11.phx.gbl...
In a Managed C++ module, I have a function returning an integer as
output parameter:

bool Func1( [System::Runtime::InteropServices::Out] int __gc *iout)
{
*iout = 33;
return true;
}

Calling Func1 from a C# application works correctly:

int iValue;
Func1(out iValue); // iValue correctly returned as 33

However, if using s struct parameter, I don't get the data returned

MC++:

__value struct MyStruct
{
public __value double dVal1;
public __value double dVal2;
};

MyStruct m_data; // membe var

bool Func2( [System::Runtime::InteropServices::Out] MyStruct __gc *pOut)
{
m_data.dVal1 = 11;
m_data.dVal2 = 22;

*pOut = m_data; // does not work - crashes application

pOut = &m_data; // Function call succeedes, but m_data does not
arrive in C# app
return true;
}

C#:

MyStruct data = new MyStruct ();
Func2(out data); // data is empty

How do I pass a struct output parameter correctly from MC++ to C# ???
Any help is appreciated
Regards Urs

Nov 15 '05 #2

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

Similar topics

3
by: Gordon Scott | last post by:
Hi All, I've got a problem I'm seeing when trying to use the struct module to send data to a different machine. Actually I'm making a condensed file that gets transferred to and read on a BREW...
4
by: James Harris | last post by:
Having updated my Debian system it now complains that I am using an incompatible pointer type in warnings such as "passing arg 2 of 'bind' from incompatible pointer type" from code, struct...
12
by: Dennis Schulz | last post by:
hi alle, ich bin blutiger C Anfänger und hier ist mein Versuch ein Strukt in eine Datei zu schreiben, bzw anzuhängen. Leider wird die datei zwar angelegt aber nichts reingeschrieben. Besonders...
4
by: quek | last post by:
Im having a problem passing a struct ptr. Maybe someone could help me. Heres what Visual C gives me as error: error C2664: 'adpcm_coder_u' : cannot convert parameter 4 from 'struct main::$S1 *'...
1
by: jconnort | last post by:
I'm trying to write a function to get the current system time, so I can use it when I need to output it to a log, below is the code I'm testing: #include "include.h" #include <stdlib.h> ...
5
by: jwright | last post by:
I have decided to use a struct to collect my data. The input file is comma dilineated between almost all of the fields. Here is the code I have so far and a sample input and output file. ...
14
by: Lane Straatman | last post by:
I would like to write a 'struct'. I have a library that is all but completely inappropriate for this task. So I'm looking for C code that fills in the gaps between: #undef...
4
by: castironpi | last post by:
I'd like to seriously nominate this idea and get a considered opinion on it. struct.Struct lets you encode Python objects into structured memory. It accepts a format string, and optionally a...
4
by: Sheldon | last post by:
Hi, I have a unique case where I need an array of structs that grows and within this array is another struct that grows in some cases. I'm having trouble allocating memory. Since I have never...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.