整个C / C共同的定义++(非托管)和托管C#code [英] Shared common definitions across C/C++ (unmanaged) and managed C# code
问题描述
我有一组由两个C#托管组件和非托管的C / C ++组件使用结构定义。眼下,相同结构的定义在C / C ++和C#code独立存在 - 重复造成和相关混乱。什么是维护,可以从C#和C / C ++使用单一定义的最佳方式?
谢谢!
阿米特
I have a set of struct definitions that are used by both C# managed components and unmanaged C/C++ components. Right now, the identical struct definitions exist separately in C/C++ and C# code - causing duplication and related chaos. What's the best way to maintain single definitions that can be used from both C# and C/C++? Thanks! Amit
P.S:我是一个C / C ++的家伙,所以如果有这样做一个显而易见的方式,我可能会完全丢失了!
P.S.: I'm a C/C++ guy so if there's an obvious way to do this, I might be missing it completely!
推荐答案
我不熟悉你的项目上,很明显,但你有没有考虑在的 C ++ / CLI ?随着它只是工作hackering的C ++ / CLI编译器为你做,你会无数次能够调集和共享托管类型与本地code和来回。
I'm not familiar with your project(s), obviously, but have you considered building a managed bridge for your library in C++/CLI? With the "It Just Works" hackering the C++/CLI compiler does for you, many times you'll be able to marshal and share managed types with native code and back and forth.
同样,我不知道它是否适合你没有更多的细节,但它可能是值得研究的。
Again, I don't know if it's right for you without more specifics, but it might be worth looking into.
这篇关于整个C / C共同的定义++(非托管)和托管C#code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!