mirror of
https://github.com/Atmosphere-NX/Atmosphere-libs.git
synced 2025-06-28 14:02:40 +02:00
libstrat: add R_TRY helper macro.
This commit is contained in:
parent
1477f2d634
commit
8e650c8ff7
@ -16,6 +16,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
/* Utilities. */
|
||||
#include "results/utilities.h"
|
||||
|
||||
/* Official. */
|
||||
#include "results/creport_results.hpp"
|
||||
#include "results/debug_results.hpp"
|
||||
|
25
include/stratosphere/results/utilities.h
Normal file
25
include/stratosphere/results/utilities.h
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @file result_utilities.h
|
||||
* @brief Utilities for handling Results.
|
||||
* @author SciresM
|
||||
* @copyright libnx Authors
|
||||
*/
|
||||
#pragma once
|
||||
#include <switch/result.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/// Evaluates an expression that returns a result, and returns the result if it would fail.
|
||||
#define R_TRY(res_expr) \
|
||||
do { \
|
||||
const Result _tmp_r_try_rc = res_expr; \
|
||||
if (R_FAILED(_tmp_r_try_rc)) { \
|
||||
return _tmp_r_try_rc; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user