SDL_SetAssertionHandler
Use this function to set an application-defined assertion handler.
使用该函数设置一个应用程序指定的断言处理函数。
Syntax 语法
void SDL_SetAssertionHandler(SDL_AssertionHandler handler, void* userdata)
Function Parameters 函数参数
参数名 | 解释 |
---|---|
handler | the function to call when an assertion fails or NULL for the default handler; see Remarksfor details. 当断言失败时要调用的函数或者填入NULL使用默认的处理函数。注释 中有详细说明。 |
serdata | a pointer that is passed to handler. 传入到处理函数的数据指针。 |
Code Examples 代码示例
暂无。
Remarks 注释
This function allows an application to show its own assertion UI and/or force the response to an assertion failure. If the application doesn’t provide this, SDL will try to do the right thing, popping up a system-specific GUI dialog, and probably minimizing any fullscreen windows.
该函数允许应用程序显示它自己的断言界面和/或强制断言的回应失败。如果程序中没有指定,SDL 会尝试做正确的行为,弹出一个系统特定的对话框,并且尝试最小化所有全屏的窗口。
The function prototype for handler is:
handler 的函数原型是:
SDL_AssertState YourAssertionHandler(const SDL_AssertData* data, void* userdata)
- where
YourAssertionHandler
is the name of your function and its parameters are: 其中
YourAssertionHandler
是你声明的函数名字,参数为:data a pointer to the SDL_AssertData structure corresponding to the current assertion
一个用来表示当前断言的 SDL_AssertData 结构体指针。userdata what was passed as userdata to SDL_SetAssertionHandler()
传入 SDL_SetAssertionHandler() 中作为 userdata 参数的数据指针。This callback should return an SDL_AssertState value indicating how to handle the assertion failure.
- 该回调函数应返回一个用于表示如何处理断言失败的 SDL_AssertState 值。
This callback may fire from any thread, but it runs wrapped in a mutex, so it will only fire from one thread at a time.
该回调函数可能会从任何线程触发,但由于它是在互斥体中封装的,所以一次只会从一个线程中触发。
This callback is NOT reset to SDL’s internal handler upon SDL_Quit()!
该函数不会因调用 SDL_Quit() 而被重置为 SDL 的内部处理函数。