reinterpret_cast 运算符是用来处理无关类型之间的转换。
其典型使用场景是用在任意指针(或引用)类型之间的转换
参见以下的 google breakpad 的相关代码
typedef void* BREAKPAD_HANDLE;
extern "C" BREAKPAD_HANDLE initialize_breakpad(char const* dump_path)
{
google_breakpad::MinidumpDescriptor descriptor(dump_path);
auto handler = new google_breakpad::ExceptionHandler(
descriptor,
nullptr, // Callback before starting the minidump.
dump_callback, // Callback after writing the minidump.
nullptr, // Callback context.
true, // Write a minidump for any unhandled exception.
-1); // Write minidumps in-process, for simplicity.
return reinterpret_cast<BREAKPAD_HANDLE>(handler);
}
近期评论