Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including a C++ header file in a c# file

I was converting a Managed c++ project to a C# one. The C++ project includes a constants C++ header file which is an external dependency present outside of the project.

In the newly created C# file, is there a way to include this C++ header file? I dont want to redefine these constants in a C# file as changes by clients will take place on the C++ header file.

like image 227
Tyler Durden Avatar asked Mar 23 '23 22:03

Tyler Durden


1 Answers

It's not possible to include it.

You have 2 options really

  • duplicate it for the managed layer, and maintain it in synch with the C++ header.
  • read and parse it at runtime, and use reflection in the C# parts that require those symbols.

As noted by others, you can automate the first one.

like image 149
SteveLove Avatar answered Mar 29 '23 17:03

SteveLove