comparison foosdk/sdk/libPPUI/win32_op.h @ 1:20d02a178406 default tip

*: check in everything else yay
author Paper <paper@tflc.us>
date Mon, 05 Jan 2026 02:15:46 -0500
parents
children
comparison
equal deleted inserted replaced
0:e9bb126753e7 1:20d02a178406
1 #pragma once
2
3 PFC_NORETURN PFC_NOINLINE void WIN32_OP_FAIL();
4 PFC_NORETURN PFC_NOINLINE void WIN32_OP_FAIL_CRITICAL(const char * what);
5
6 #ifdef _DEBUG
7 void WIN32_OP_D_FAIL(const wchar_t * _Message, const wchar_t *_File, unsigned _Line);
8 #endif
9
10 //Throws an exception when (OP) evaluates to false/zero.
11 #define WIN32_OP(OP) \
12 { \
13 SetLastError(NO_ERROR); \
14 if (!(OP)) WIN32_OP_FAIL(); \
15 }
16
17 // Kills the application with appropriate debug info when (OP) evaluates to false/zero.
18 #define WIN32_OP_CRITICAL(WHAT, OP) \
19 { \
20 SetLastError(NO_ERROR); \
21 if (!(OP)) WIN32_OP_FAIL_CRITICAL(WHAT); \
22 }
23
24 //WIN32_OP_D() acts like an assert specialized for win32 operations in debug build, ignores the return value / error codes in release build.
25 //Use WIN32_OP_D() instead of WIN32_OP() on operations that are extremely unlikely to fail, so failure condition checks are performed in the debug build only, to avoid bloating release code with pointless error checks.
26 #ifdef _DEBUG
27 #define WIN32_OP_D(OP) \
28 { \
29 SetLastError(NO_ERROR); \
30 if (!(OP)) WIN32_OP_D_FAIL(PFC_WIDESTRING(#OP), PFC_WIDESTRING(__FILE__), __LINE__); \
31 }
32
33 #else
34 #define WIN32_OP_D(OP) (void)( (OP), 0);
35 #endif
36