A
andrew queisser
Hi all,
The question of reusing C header files in C# comes up frequently and there's
really no general solution. I do have a specific problem that I think can be
solved and I'd like to get some feedback on.
I have a C# app that communicates with an embedded C app via UDP packets. I
have to ensure that both sides see the exact same data structure. I know how
to do this by defining classes with attributes in C# and defining the
appropriate header and compiler switches on the embedded system.
I'm wondering if I can have a single source that defines the structure for
both systems. Right now I can envision the following solutions:
1) Write a utility that parses the C header and generates the C# class
definition.
2) Write a utility that parses some other file format (XML, etc.) and
generates both the header and the C# class definition
3) Use C++/CLI to somehow generate a .NET type that gets imported into the
C# app.
Solutions 1) and 2) are doable but seem kind of tedious and boring. Anyone
know if tools like this exist? The C headers have not been written yet and
they will be quite simple. No need to parse exotic C constructs.
Solution 3) seems a little more interesting but is it doable?
Thanks for any comments,
Andrew Queisser
The question of reusing C header files in C# comes up frequently and there's
really no general solution. I do have a specific problem that I think can be
solved and I'd like to get some feedback on.
I have a C# app that communicates with an embedded C app via UDP packets. I
have to ensure that both sides see the exact same data structure. I know how
to do this by defining classes with attributes in C# and defining the
appropriate header and compiler switches on the embedded system.
I'm wondering if I can have a single source that defines the structure for
both systems. Right now I can envision the following solutions:
1) Write a utility that parses the C header and generates the C# class
definition.
2) Write a utility that parses some other file format (XML, etc.) and
generates both the header and the C# class definition
3) Use C++/CLI to somehow generate a .NET type that gets imported into the
C# app.
Solutions 1) and 2) are doable but seem kind of tedious and boring. Anyone
know if tools like this exist? The C headers have not been written yet and
they will be quite simple. No need to parse exotic C constructs.
Solution 3) seems a little more interesting but is it doable?
Thanks for any comments,
Andrew Queisser