-#define ON_BLOCK_EXIT1(f, p1) \
- wxScopeGuard wxMAKE_UNIQUE_NAME(scopeGuard) = wxMakeGuard(f, p1); \
- wxPrivate::Use(wxMAKE_UNIQUE_NAME(scopeGuard))
-
-#define ON_BLOCK_EXIT_OBJ1(o, m, p1) \
- wxScopeGuard wxMAKE_UNIQUE_NAME(scopeGuard) = wxMakeObjGuard(o, m, p1); \
- wxPrivate::Use(wxMAKE_UNIQUE_NAME(scopeGuard))
-
-#define ON_BLOCK_EXIT2(f, p1, p2) \
- wxScopeGuard wxMAKE_UNIQUE_NAME(scopeGuard) = wxMakeGuard(f, p1, p2); \
- wxPrivate::Use(wxMAKE_UNIQUE_NAME(scopeGuard))
-
-#define ON_BLOCK_EXIT_OBJ2(o, m, p1, p2) \
- wxScopeGuard wxMAKE_UNIQUE_NAME(scopeGuard) = wxMakeObjGuard(o, m, p1, p2); \
- wxPrivate::Use(wxMAKE_UNIQUE_NAME(scopeGuard))
+#define wxGuardName wxMAKE_UNIQUE_NAME(scopeGuard)
+
+#define wxON_BLOCK_EXIT0_IMPL(n, f) \
+ wxScopeGuard n = wxMakeGuard(f); \
+ wxPrivate::Use(n)
+#define wxON_BLOCK_EXIT0(f) \
+ wxON_BLOCK_EXIT0_IMPL(wxGuardName, f)
+
+#define wxON_BLOCK_EXIT_OBJ0_IMPL(n, o, m) \
+ wxScopeGuard n = wxMakeObjGuard(o, m); \
+ wxPrivate::Use(n)
+#define wxON_BLOCK_EXIT_OBJ0(o, m) \
+ wxON_BLOCK_EXIT_OBJ0_IMPL(wxGuardName, o, m)
+
+#define wxON_BLOCK_EXIT1_IMPL(n, f, p1) \
+ wxScopeGuard n = wxMakeGuard(f, p1); \
+ wxPrivate::Use(n)
+#define wxON_BLOCK_EXIT1(f, p1) \
+ wxON_BLOCK_EXIT1_IMPL(wxGuardName, f, p1)
+
+#define wxON_BLOCK_EXIT_OBJ1_IMPL(n, o, m, p1) \
+ wxScopeGuard n = wxMakeObjGuard(o, m, p1); \
+ wxPrivate::Use(n)
+#define wxON_BLOCK_EXIT_OBJ1(o, m, p1) \
+ wxON_BLOCK_EXIT_OBJ1_IMPL(wxGuardName, o, m, p1)
+
+#define wxON_BLOCK_EXIT2_IMPL(n, f, p1, p2) \
+ wxScopeGuard n = wxMakeGuard(f, p1, p2); \
+ wxPrivate::Use(n)
+#define wxON_BLOCK_EXIT2(f, p1, p2) \
+ wxON_BLOCK_EXIT2_IMPL(wxGuardName, f, p1, p2)
+
+#define wxON_BLOCK_EXIT_OBJ2_IMPL(n, o, m, p1, p2) \
+ wxScopeGuard n = wxMakeObjGuard(o, m, p1, p2); \
+ wxPrivate::Use(n)
+#define wxON_BLOCK_EXIT_OBJ2(o, m, p1, p2) \
+ wxON_BLOCK_EXIT_OBJ2_IMPL(wxGuardName, o, m, p1, p2)