How to use C++ declarations in C# or vice versa?

Announcements and discussion for PInvoke

Moderators: Luke Jefferson, Robert

How to use C++ declarations in C# or vice versa?

Postby Rambutan » Thu Jul 26, 2007 5:21 pm

From a program written in C#, I want to use a DLL written in C++ to manipulate a variety of simple structures, containing both integer and floating point data. Is there a way to gather the declarations into a single place, like the header.h file one would use if the project were written entirely in C++? The code is still evolving on both sides, and having duplicate sets of declarations for the same structures in two different places is both tedious and error-prone.
Rambutan
 
Posts: 1
Joined: Thu Jul 26, 2007 4:27 pm

Postby Robert » Thu Jul 26, 2007 8:22 pm

Hi,

To the best of my knowledge, there isn't a way you can share a set of declarations or headers between (unmanaged) C++ and C#. For neatness, you could group the C# P/Invoke declarations into their own static class, like a "Header.cs", which corresponds to your C++ header.h, but you'd still need to keep the two synchronized by hand.

Robert
Robert Chipperfield
Red Gate
Robert
 
Posts: 410
Joined: Mon Oct 30, 2006 11:15 am
Location: Cambridge, UK


Return to PInvoke.Net

Who is online

Users browsing this forum: No registered users and 0 guests