473,387 Members | 1,611 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.

Converting Int32 * to int * for CLS compliancy.

While I'm experienced with c# and regular c++, I'm very new to managed
c++ so please bare with me.

Here's the scenario:

I have a function that wraps a pointer to an unmanaged function. I want
the wrapping function to be CLS compliant.

Here's what I have now. It works perfectly, but isn't CLS compliant:

void gle::GenBuffersARB( int number, int * buffer )
{
glGenBuffersARB(number, buffer);
}

glGenBuffersARB is the pointer to the unmanaged function. The second
parameter must be a pointer to an unmanaged int. I tried using Int32s
in the function pointer declaration, but that causes
system.typeloadexception. And before you mention it, yes I do have to
use a function pointer to use this function, you can't do simple
external declarations for OpenGL extensions.

I would like something like this:

void gle::GenBuffersARB( Int32 number, Int32 * buffer )

This is CLS compliant: the second parameter is seen as ref int by c# and
byref by vb.net.

How would I convert a reference to a managed Int32 into a pointer to an
unmanaged int? I looked at __box, but that creates a copy. This won't
work because glGenBuffersARB must change the original "buffer" int
passed to the wrapping function. Even if I could do something like
this, that would help:

copy numbers from Int32 buffer to a new int
pass pointer to the new int to glGenBuffersARB
copy the modified numbers in the int back to the Int32
Nov 17 '05 #1
1 1394
haha never mind, a blonde moment. I whipped up a very easy solution:

void gle::GenBuffersARB( Int32 number, Int32 * buffer )
{
int tempbuffer = *buffer;
int tempnumber = number;

gle::glGenBuffersARB( tempnumber, &tempbuffer );
*buffer = tempbuffer;
}

voila
Nov 17 '05 #2

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

Similar topics

3
by: Caleb Hattingh | last post by:
Hi all I saw it on a webpage a few days ago, can't seem to find it again. Tried a google search for "pypy needed translate C modules" but that didn't turn up what I was looking for. ...
11
by: spipyeah | last post by:
Is there a collection of C++ source files that can be used to test compiler compliancy by using really extreme language cases, making sure the standard library is complete, and other such things?
1
by: Majed | last post by:
hi, I'm trying to convert some .h files to API Declaration to use the function and structs. one of it is this: NTMS_GUID CurrentLibrary; // the current library NTMS_GUID MediaPool; // media...
5
by: P. | last post by:
Hi, I'm looking for a set of C tests/library which can be used to check ANSI C (C99) compliancy. For instance a set of C tests which can be used to test compiler ANSI C compliancy. I...
3
by: VBDotNETCoder | last post by:
Does any one know of any 508 Compliancy Tools for ASP.NET to help automate the process before deployment.
6
by: Ramakrishnan Nagarajan | last post by:
Hi can any one help me in converting a DataView into a DataSet or a DataTable into a DataSet, I tried the following ways dSet= ((DataSet)_gridRegStudDetails.DataSource); dSet =...
3
by: HKannen | last post by:
Hello Everybody, I wrote a little method that gets me an Int32 from a BitArray. This method looks like this: private Int32 GetIntVal( BitArray iArray ) { Byte lByteArr = new Byte; ...
5
by: vtjumper | last post by:
I'm building a C# interface to an existing messaging system. The messaging system allows values of several types to be sent/recieved over the interface. What I want to do is use a generic...
2
by: chriscoder33309 | last post by:
greetings all. I am now coding in Java due to a new employer and was previously a C#/vb.net coder. I wanted to know how to accomplish the below in Java (NetBeans). In C# I always separated my web...
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: 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: 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
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
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.