"Dean Mitchell" <not (AT) this (DOT) address> wrote
Quote:
Hi everyone,
We have a c++ server application that we are writing a GUI client
application for. To save our time and to avoid duplicating all the code
and functionality that already exists in c++ classes I am building a
managed c++ assembly around these classes so that a c# program can use
them.
The problem is that alot of these c++ classes use enums, I would like to
make these visible to the c# application but I cannot find a way to do
this. Do I have to duplicate them so that I have one lot for C++ and the
other for dotnet? There must be an easier way? |
Put the innards of the enum into a separate header file, then #include it
twice:
enum NativeEnum {
#include "enum.h"
};
enum class ManagedEnum {
#include "enum.h"
};
Or, someone else had a really nifty idea.
Write the enum in native form, then it's also a valid C# file. So your
native C++ code contains:
#include "enum.cs"
The C# code just has that file included in the project. If you want the
enum to be public in C#, you'll end up with something like:
#define public
#include "enum.cs"
#undef public