Ways/tools to use C++ header file in c#

  • Thread starter Thread starter weixian_shen
  • Start date Start date
W

weixian_shen

I need to make use of my previous workin C++. This involves very
complex data structure, over 5000 lines of data structure defined in
headers. Is there an easy way to convert those headers into C#?
 
I have a very unsupported tool that uses DIA SDK to read the type
information from a C++ PDB file. If you want to give it a shot - it is at
http://www.alexfeinman.com/download.asp?doc=DiaTest.zip

It comes with the source code, so you can tinker with the output. Right now
it will try to create a class based on a base class that provides byte array
marshalling. The PDB file that it needs must come from compiling a debug
build of a C++ application
 
Thank you, Alex. I tried your tool, but it crashed while trying to load
the PDB (it is created in VC6 SP3). But this seemed a long way around.
I have all the source, just need a converter. I'm surprise few people
have come across this problem, as I'd imagine any software company will
have millions of lines of headers.
 
First, I suggest you use eVC 4 PDB. Second, this needs to be a machine with
VS2003 installed. I don't remember if VC6 had the DIA component.
Now as for your other point, no you don't need a converter. The thing is
that the converter will have to parse the .H file paying attention to the
packing and defines. It is very hard to do it reliably and that's why there
are no converters (at least not the one that works in most of cases). But
there is already such parser - it is the C++ compiler itself. The PDB file
contains both type and layout information and thus is a more attractive
source.

If you want to zip your PDB file and send it to me, I could try creating a
structure P/Invoke definition for you
 
Back
Top