Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 11-Mar-19 16:43pm
v3
Comments
CPallini 11-Mar-19 15:25pm    
Please give a detailed description of your scenario.
Rick York 11-Mar-19 16:08pm    
Personally, I have had very poor luck doing that. When I have made C wrappers around the library's functions everything worked just fine.
Member 10068530 11-Mar-19 16:29pm    
I think you still need to include the headers with c wrapper. Were you able to do it without including header files?
Rick York 11-Mar-19 17:00pm    
Yes, but we still had to define the C interface prototypes for the application. This can be done through a header file or just inline for the app but it was not required for the library because it had no use for the prototypes. We did it inline so we didn't need another header file.

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900