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

Pointers and C#

1) We create an assembly with Managed Extensions for C++ named
some_name.dll. This assembly has source code like the following

Byte * some_method() // a method returning a pointer, defined within some
class
{
....
}

This assembly is created with VS2003, i.e. it is a .NET 1.1 assembly.

2) We then create an application in C# using the assembly of step 1. In this
application we try to use some_method from the assembly. When we compile
this application with C# in VS2003 everything is fine: the C# compiler
issues no error message and the function works as expected when executed.

3) When we compile the same C# code with C# in VS2005, the compiler issues
the error message: "language does not support this construct". Using other
methods which do not use pointers from the same assembly still works
properly.

Clearly something must have changed between C#/VS2003 and C#/VS2005 with
regards to using pointers. It would be instructive to know what has been
changed. Furthermore, how can the issue be dealt with and worked around?

Peter
Dec 18 '07 #1
1 1459
I don't have an answer, just some advice - *don't* use Managed Extensions for
C++ (VC++ 2003). This was horribly buggy and the entire 2003 syntax was
thrown out for 2005, replace by C++/CLI.
--
http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
C++ to Ruby
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB or C# to C++/CLI
"Peter" wrote:
1) We create an assembly with Managed Extensions for C++ named
some_name.dll. This assembly has source code like the following

Byte * some_method() // a method returning a pointer, defined within some
class
{
....
}

This assembly is created with VS2003, i.e. it is a .NET 1.1 assembly.

2) We then create an application in C# using the assembly of step 1. In this
application we try to use some_method from the assembly. When we compile
this application with C# in VS2003 everything is fine: the C# compiler
issues no error message and the function works as expected when executed.

3) When we compile the same C# code with C# in VS2005, the compiler issues
the error message: "language does not support this construct". Using other
methods which do not use pointers from the same assembly still works
properly.

Clearly something must have changed between C#/VS2003 and C#/VS2005 with
regards to using pointers. It would be instructive to know what has been
changed. Furthermore, how can the issue be dealt with and worked around?

Peter
Dec 18 '07 #2

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

Similar topics

27
by: Susan Baker | last post by:
Hi, I'm just reading about smart pointers.. I have some existing C code that I would like to provide wrapper classes for. Specifically, I would like to provide wrappers for two stucts defined...
3
by: ozbear | last post by:
This is probably an obvious question. I know that pointer comparisons are only defined if the two pointers point somewhere "into" the storage allocated to the same object, or if they are NULL,...
9
by: Mikhail Teterin | last post by:
Hello! I'd like to have a variable of a pointer-to-function type. The two possible values are of type (*)(FILE *) and (*)(void *). For example: getter = straight ? fgetc : gzgetc; nextchar...
12
by: Lance | last post by:
VB.NET (v2003) does not support pointers, right? Assuming that this is true, are there any plans to support pointers in the future? Forgive my ignorance, but if C# supports pointers and C# and...
14
by: Alf P. Steinbach | last post by:
Not yet perfect, but: http://home.no.net/dubjai/win32cpptut/special/pointers/ch_01.pdf http://home.no.net/dubjai/win32cpptut/special/pointers/ch_01_examples.zip To access the table of...
92
by: Jim Langston | last post by:
Someone made the statement in a newsgroup that most C++ programmers use smart pointers. His actual phrase was "most of us" but I really don't think that most C++ programmers use smart pointers,...
4
by: Josefo | last post by:
Hello, is someone so kind to tell me why I am getting the following errors ? vector_static_function.c:20: error: expected constructor, destructor, or type conversion before '.' token...
25
by: J Caesar | last post by:
In C you can compare two pointers, p<q, as long as they come from the same array or the same malloc()ated block. Otherwise you can't. What I'd like to do is write a function int comparable(void...
54
by: Boris | last post by:
I had a 3 hours meeting today with some fellow programmers that are partly not convinced about using smart pointers in C++. Their main concern is a possible performance impact. I've been explaining...
2
by: StevenChiasson | last post by:
For the record, not a student, just someone attempting to learn C++. Anyway, the problem I'm having right now is the member function detAddress, of object controller. This is more or less, your...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.