Link to home
Start Free TrialLog in
Avatar of Barbless
Barbless

asked on

Software Engineer

Is it possible in C# to use the  structs defined in an unmanaged header file?
ASKER CERTIFIED SOLUTION
Avatar of gregoryyoung
gregoryyoung
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Barbless
Barbless

ASKER

Is there any other way out?

What I'm trying to avoid is to have 2 sets of struct definitions, one for C# and the other for C. This way, I don' t have to worry about breaking the SW if one is changed but forgot to make corresponding change to the other.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks gregoryyoung and josgood, I think I'll write the conversion util, as you both suggested.

One question though, how do I read the converted file in C#? Would it be something simple like using "using"?
Sounds like you want to write the conversion utility to take a C header and emit a C# .cs file.

I've assumed all along that you would include the .cs file in your project.
well you could compile it into a .dll and use using ... or you could just include the .cs files in your compile (or add to your project if you build through VS.NET)