C++/CLI : Casting from unmanaged enum to managed enum

前端 未结 2 1360
我寻月下人不归
我寻月下人不归 2020-12-25 12:49

What is the correct way of casting (in C++/CLI) from a native code enum to a managed code enum which contain the same enum values? Is

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-25 13:32

    It depends. for example, if you have a CLI enum that has an underlying type of ushort, it cannot hold a vallue of 257. By default the CLI enum is based on int, which should be fine in most cases. If your native C++ code use unsigned 32bit ints/64bit ints as the underlying type if enums, switch the base of your CLI enum to UInt32, long or ulong.

提交回复
热议问题