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

int return parameter between C# and mc++

I am invoking a mc++ method from C# via an unsafe code block. The reason for
the unsafe code block is that I am receiving a int as a return parameter. I
am invoking the method with a "ref iValue" int parameter.... and in the mc++
code I define "int* iValue" for the same int parameter. As a result I have
to place the invoking code in an unsafe code block.

Is there not a means to update a int parameter between C# and mc++ without
requiring the use of an unsafe code block ?

Thanks
--
Philip
Nov 16 '05 #1
3 1525
As I answered in your other posting:

Or in a "safe" context:

C#
c.ModInt(ref i);

C++
1)
void ModInt3(System::Int32& i)
{
i = 13;
}

2)
void ModInt3(System::Int32* i)
{
*i = 13;
}

Willy.

"Philip" <ph****@softwareforever.com> wrote in message
news:D4**********************************@microsof t.com...
I am invoking a mc++ method from C# via an unsafe code block. The reason
for
the unsafe code block is that I am receiving a int as a return parameter.
I
am invoking the method with a "ref iValue" int parameter.... and in the
mc++
code I define "int* iValue" for the same int parameter. As a result I
have
to place the invoking code in an unsafe code block.

Is there not a means to update a int parameter between C# and mc++ without
requiring the use of an unsafe code block ?

Thanks
--
Philip

Nov 16 '05 #2
OK...this works fine.

One more related question. What if I prefer to invoke the method with the
"out" modifier.... like...

C#
c.ModInt(out i);

How is the parameter defined in mc++ to accomodate the "out" requirement ?

Thanks

Philip

"Willy Denoyette [MVP]" wrote:
As I answered in your other posting:

Or in a "safe" context:

C#
c.ModInt(ref i);

C++
1)
void ModInt3(System::Int32& i)
{
i = 13;
}

2)
void ModInt3(System::Int32* i)
{
*i = 13;
}

Willy.

"Philip" <ph****@softwareforever.com> wrote in message
news:D4**********************************@microsof t.com...
I am invoking a mc++ method from C# via an unsafe code block. The reason
for
the unsafe code block is that I am receiving a int as a return parameter.
I
am invoking the method with a "ref iValue" int parameter.... and in the
mc++
code I define "int* iValue" for the same int parameter. As a result I
have
to place the invoking code in an unsafe code block.

Is there not a means to update a int parameter between C# and mc++ without
requiring the use of an unsafe code block ?

Thanks
--
Philip


Nov 16 '05 #3
Specify the OutAttribute on the formal argument you want to pass as out.
Note that this attribute only as a real value when using interop (COM or
PInvoke), but here it
makes the CSsharp compiler happy ;-)

ModInt(out i);

...

MC++
void ModInt([System::Runtime::InteropServices::OutAttribute]
System::Int32& i)
{
i = 3;
}

Willy.

"Philip" <ph****@softwareforever.com> wrote in message
news:F8**********************************@microsof t.com...
OK...this works fine.

One more related question. What if I prefer to invoke the method with
the
"out" modifier.... like...

C#
c.ModInt(out i);

How is the parameter defined in mc++ to accomodate the "out" requirement ?

Thanks

Philip

"Willy Denoyette [MVP]" wrote:
As I answered in your other posting:

Or in a "safe" context:

C#
c.ModInt(ref i);

C++
1)
void ModInt3(System::Int32& i)
{
i = 13;
}

2)
void ModInt3(System::Int32* i)
{
*i = 13;
}

Willy.

"Philip" <ph****@softwareforever.com> wrote in message
news:D4**********************************@microsof t.com...
>I am invoking a mc++ method from C# via an unsafe code block. The
>reason
>for
> the unsafe code block is that I am receiving a int as a return
> parameter.
> I
> am invoking the method with a "ref iValue" int parameter.... and in the
> mc++
> code I define "int* iValue" for the same int parameter. As a result I
> have
> to place the invoking code in an unsafe code block.
>
> Is there not a means to update a int parameter between C# and mc++
> without
> requiring the use of an unsafe code block ?
>
> Thanks
> --
> Philip


Nov 16 '05 #4

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

Similar topics

4
by: Daniel Lidström | last post by:
Hi, I've been trying a long time now to generate some XML using MC++ and XmlSerializer. I have a piece of C# code that produces exactly what I want, but I simply can't get the MC++ code to write...
0
by: Peter Insley via .NET 247 | last post by:
Hi, have been searching for an answer for this for quite a while,I would be greatfull for any help. We are developing a codebase that of components that we wouldlike to be able to write in MC++ or...
2
by: tzvika.visman | last post by:
I write a MC++ wrapper for our company internal SDK that wrote in C++ native code for writing application with this SDK over C# and other .NET languages and most of my SDK API function return a...
1
by: Zoran Stipanicev | last post by:
Hi! Does anyone knows how to get the same functionality like in native c++ code shown below, in cli. To be more precise I don't know what to write in place of question marks in cli code below....
0
by: Managed Code | last post by:
Hello, I have a status and definition table. The status table's current status field relates the ID field of the definition table. I am trying to retrieve the definitions that are associated...
8
by: WebSnozz | last post by:
I have an application written in C that does a lot of low level stuff. It does a lot of things like casting from void*'s. I want to create a new GUI for it in either C# or MC++, but reuse the...
5
by: Jeremy Chaney | last post by:
Forgive me if this is a dumb question. It seems like such a simple thing that I shouldn't have to ask, but alas, I can't seem to figure it out. I'm porting some C++ code to MC++ and I have a...
3
by: Bruno LIVERNAIS | last post by:
Hi, We are currently installing a DB2 V9 ESE on a Linux server (RHEL4U4-x86_64). Installation runs successfully on each node. Database user environment is OK and the instance is well created. To...
11
by: Juha Nieminen | last post by:
I'm writing an STL-style data container, and this problem is puzzling me. The following code should demonstrate the problem: //---------------------------------------------------------- #include...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
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
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,...

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.