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

Announcements and discussion for PInvoke

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

Postby Rambutan » Thu Jul 26, 2007 4: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.
Posts: 1
Joined: Thu Jul 26, 2007 3:27 pm

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


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 Chipperfield
Red Gate
Posts: 418
Joined: Mon Oct 30, 2006 10:15 am
Location: Cambridge, UK

Return to PInvoke.Net

Who is online

Users browsing this forum: No registered users and 0 guests