I have a function in C that takes a hexadecimal parameter. I need to call this function from C #. My current approach does not seem to be correct, because my C function returns me the wrong number.
Here is the declaration of my C function:
enum tags { TAG_A = -1, TAG_B = 0x00, TAG_C = 0xC1, ... }; int myfunction(enum tags t);
Here is my C # code:
enum tags { TAG_A = -1, TAG_B = 0x00, TAG_C = 0xC1, ... } [DllImport ("mylibraryname")] public static extern int myfunction(tags t); myfunction(tags.TAG_B);
I am on a Mac and I use Mono and Xcode to do all of this. The C function can be considered correct because I am loading the open source library. I think something is wrong with hexadecimal numbers, but I'm not sure.
Decision:
I ticked one answer, although actually setting up C # overflow has long resolved my problem. So in C # I have:
enum tags: long {TAG_A = -1, TAG_B = 0x00, TAG_C = 0xC1, ...}
source share