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

MC++ passing pointer to 'int'

I need to pass a pointer to 'int' as a parameter in a managed module to a
managed member function. I am assuming I need to box my value. Is this true,
or can I just pass the address of my variable ? The variable needs to
conform to CLS specifications.
Nov 16 '05 #1
2 1080
Hi Edward,

Ref parameters are part of CLS. Just pass a pointer to a System::Int32 (or
equivalently, a __gc pointer to an int).

Ronald Laeremans
Visual C++ team

"Edward Diener" <ed******@tropicsoft.com> wrote in message
news:ux****************@TK2MSFTNGP12.phx.gbl...
I need to pass a pointer to 'int' as a parameter in a managed module to a
managed member function. I am assuming I need to box my value. Is this true, or can I just pass the address of my variable ? The variable needs to
conform to CLS specifications.

Nov 16 '05 #2
Ronald Laeremans [MSFT] wrote:
Hi Edward,

Ref parameters are part of CLS. Just pass a pointer to a
System::Int32 (or equivalently, a __gc pointer to an int).
I have some confusion about this. My understanding is that System::Int32 is
a value type. So this means that if I pass a pointer to a System::Int32
object, I can just instantiate one on the stack and take its address to pass
it as a pointer, since as the documentation states, there is an implicit
conversion from a V __nogc * to a V __gc * , ie.

__gc class A { void SomeMemberFunction(System::Int32 *); }
// System::Int32 * is a __gc pointer because System::32 is a managed type.
A * myA = new A();
System::Int32 avar;
myA -> SomeMemberFunction(&avar);

Now suppose I have an 'int' instead:

int avar;
myA -> SomeMemberFunction(&avar);

Does this work ? or do I have to do manual boxing such as:

myA -> SomeMemberFunction(__box(avar));

Ronald Laeremans
Visual C++ team

"Edward Diener" <ed******@tropicsoft.com> wrote in message
news:ux****************@TK2MSFTNGP12.phx.gbl...
I need to pass a pointer to 'int' as a parameter in a managed module
to a managed member function. I am assuming I need to box my value.
Is this true, or can I just pass the address of my variable ? The
variable needs to conform to CLS specifications.

Nov 16 '05 #3

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

Similar topics

58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
2
by: Morgan | last post by:
Thanks to all of you because I solved the problem related with my previous post. I simply made confusion with pointers to pointers and then succeeded passing the reference to the first element...
1
by: george doubleu | last post by:
hi, i'm using "gcc version 3.3.3 (Debian)" to compile the program pasted below. I get the two warnings you can see in the remarks. The second warning is perfectly OK for me, but the first one I...
11
by: truckaxle | last post by:
I am trying to pass a slice from a larger 2-dimensional array to a function that will work on a smaller region of the array space. The code below is a distillation of what I am trying to...
17
by: Charles Sullivan | last post by:
The library function 'qsort' is declared thus: void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); If in my code I write: int cmp_fcn(...); int...
2
by: Edward Diener | last post by:
In C++ an overridden virtual function in a derived class must have the exact same signature of the function which is overridden in the base class, except for the return type which may return a...
12
by: Mike | last post by:
Consider the following code: """ struct person { char *name; int age; }; typedef struct person* StructType;
4
by: =?Utf-8?B?QmlsbCBTcGFobg==?= | last post by:
I have an abstract base class defined in an MC++ class library. I then create a descendent class in a C# class library. This seems to work OK with the exception of one of the abstract member...
5
by: CapCity | last post by:
I'm sure I'm missing something simple - I do not code in C regularly, and the breaks are long enough for me to forget. The situation I have is I need to create an array but I do not know the...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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...
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...

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.