3

I am developing a software package that transmits messages. Currently I have a header file that contains definition of message IDs. My coworker is creating a software tool in C# and needs access to these IDs. What is the best way for our software to access these IDs?

More details: He and I don't have control over what language we use. He wants to make 2 copies of the same list. I am always hesitant to make copies of the same code. (There will be a lot of message IDs). Is there an easy way for both these tools to access the same ID?

Kat
  • 447
  • 2
  • 7
  • 21
  • 1
    simply use cli, have a look [here][1]. [1]: http://stackoverflow.com/questions/935664/possible-to-call-c-code-from-c – mo. Mar 22 '12 at 20:18
  • 2
    @mo.: By the way, only the shorthand `[label](URL)` syntax works in comments. The `[label][ref], [ref]: URL` stuff can only be used in other types of posts (questions, answers, etc.). Check the "help" button at the right of your comment for details. – André Caron Mar 22 '12 at 20:19
  • It's cool mo, I can still see the link. :) – Kat Mar 22 '12 at 20:22
  • it was an answer :) it was automatically converted to a comment.here is link in a nicier [-->way<--](http://stackoverflow.com/questions/935664/possible-to-call-c-code-from-c) :) – mo. Mar 22 '12 at 20:26

2 Answers2

2

You could specify the IDs in some declarative, trivial to parse grammar and have your (automatic) build process generate C# and C++ source files out of it. That way you have one single source.

hc_
  • 2,628
  • 1
  • 18
  • 19
2

C++/CLI is your friend. I had the exact same scenario in one of my projects and I found C++/CLI very usefull in this respect. My design was based on 3 layers:

C#
_______
C++/CLI
_______
C++

This way, I could easily reuse my C++ definitions without any duplications

GETah
  • 20,922
  • 7
  • 61
  • 103