I have an enum definition开发者_运维技巧 in one module(A), e.g. SUCCESS = 0, INVALID_REQ = 1 etc. Then I have another dll (module B) which has its own set of status enum. Once we add a new enum value in A, we have to manually add it to B since A is in .NET and B is C code. Beside, enum in A is only part of the status enum in B (B has its own internal status besides status from A). This seems a very tight coupling between these two modules. Any suggestions to make them less coupled? Thx!
Why not write a simple script that generates these enums based on a file during build? If you truly want to uncouple them, you will need to make someone a master and expose its content to the other side.. Likely using RCW..
What would be fun would be to use reflection here. Write a little program that reads the enum by reflection from module A, and generates a .h file for use in the c module.
精彩评论