如何在托管代码中使用c ++ 17模块? [英] How to consume c++17 modules in managed code?

查看:91
本文介绍了如何在托管代码中使用c ++ 17模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从托管的clr / c ++代码中使用c ++ 17模块。可能吗?



我尝试过的事情:



我有用c ++模块构建了一个dll。在没有转动/ clr的情况下从控制台应用程序中消耗它。一切正常。一旦我打开/ clr开关,它就不起作用。



我的clr控制台应用程序有以下命令行选项。



/ experimental:module / module:reference $(IntDir)\ mod.ifc



这个是我看到的错误

D8016'/ clr'和'/ experimental:module'命令行选项不兼容ConsoleApplication2

I want to consume c++17 modules from managed clr/c++ code. Is it possible?

What I have tried:

I have built a dll with c++ modules. Consumed it from a console application without turning /clr. Everything worked. Once i turn on /clr switch, it does not work.

My clr console application has the following command line options.

/experimental:module /module:reference $(IntDir)\mod.ifc

This is the error i am seeing
D8016 '/clr' and '/experimental:module' command-line options are incompatible ConsoleApplication2

推荐答案

(IntDir)\ mod.ifc



这是我看到的错误

D8016'/ clr'和'/ experimental:module '命令行选项不兼容ConsoleApplication2
(IntDir)\mod.ifc

This is the error i am seeing
D8016 '/clr' and '/experimental:module' command-line options are incompatible ConsoleApplication2


有很多方法可以做到这一点:

1.将C ++ 17实现为DLL并导出C函数接口。谷歌有很多材料如何从CLR或.Net langs调用DLL。

2.实现为COM DLL。这个可以被任何语言调用VB,C#,C ++,C等

3.实现为COM EXE服务器。这个可以被任何语言调用,它可以构建为32位,可以从64位进程调用。反之亦然。它被称为进程外服务器。

4.将其实现为Windows服务并通过RPC调用它。例如命名管道或TCP。

5.将其实现为普通exe并再次通过RPC等调用。
There are many ways you can do that:
1. Implement your C++ 17 as DLL and export "C" function interface. There are ton of material on google how to call DLLs from CLR or .Net langs.
2. Implement as COM DLL. This one can be called by any language VB, C#, C++, C etc
3. Implement as COM EXE server. This one can be called by any language plus it can be built as 32 bit and can be called from 64 bit process. And vice versa. It is known as an out of process server.
4. Implement it as windows service and call it via RPC. Named pipes, or TCP for example.
5. Implement it as a normal exe and call via RPC etc again.


这篇关于如何在托管代码中使用c ++ 17模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆