开发者

What are best practices for using IntPtr vs. void* in C++/CLI?

I'm using it for passing native pointers between assemblies. It's unfortunate that strong typing goes out the window in that context. Or at least, I haven't figured out how to get cross-assembly access to a C++/CLI method that returns a pointer to 开发者_运维知识库a native UDT. So assuming I'm right that either IntPtr or void* is necessary here, which should I use?


Always prefer the CLS-compliant route, in this case IntPtr. Not all .NET languages know what void* is, but all know what IntPtr is.

Regarding cross-assembly use of native UDTs, see #pragma make_public.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜