- Timestamp:
- Dec 22, 2018 1:00:39 AM (6 years ago)
- Location:
- trunk/include/iprt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/err.h
r76326 r76348 62 62 /* SED-START */ 63 63 64 /** Success. */ 65 #define VINF_SUCCESS 0 66 64 67 /** @name Misc. Status Codes 65 68 * @{ 66 69 */ 67 /** Success. */68 #define VINF_SUCCESS 069 70 70 /** General failure - DON'T USE THIS!!! */ 71 71 #define VERR_GENERAL_FAILURE (-1) -
trunk/include/iprt/errcore.h
r76326 r76348 36 36 * @{ 37 37 */ 38 39 /** Success. 40 * @ingroup grp_rt_err */ 41 #define VINF_SUCCESS 0 42 43 44 /** @def RTERR_STRICT_RC 45 * Indicates that RT_SUCCESS_NP, RT_SUCCESS, RT_FAILURE_NP and RT_FAILURE should 46 * make type enforcing at compile time. 47 * 48 * @remarks Only define this for C++ code. 49 */ 50 #if defined(__cplusplus) \ 51 && !defined(RTERR_STRICT_RC) \ 52 && !defined(RTERR_NO_STRICT_RC) \ 53 && ( defined(DOXYGEN_RUNNING) \ 54 || defined(DEBUG) \ 55 || defined(RT_STRICT) ) 56 # define RTERR_STRICT_RC 1 57 #endif 58 59 60 /** @def RT_SUCCESS 61 * Check for success. We expect success in normal cases, that is the code path depending on 62 * this check is normally taken. To prevent any prediction use RT_SUCCESS_NP instead. 63 * 64 * @returns true if rc indicates success. 65 * @returns false if rc indicates failure. 66 * 67 * @param rc The iprt status code to test. 68 */ 69 #define RT_SUCCESS(rc) ( RT_LIKELY(RT_SUCCESS_NP(rc)) ) 70 71 /** @def RT_SUCCESS_NP 72 * Check for success. Don't predict the result. 73 * 74 * @returns true if rc indicates success. 75 * @returns false if rc indicates failure. 76 * 77 * @param rc The iprt status code to test. 78 */ 79 #ifdef RTERR_STRICT_RC 80 # define RT_SUCCESS_NP(rc) ( RTErrStrictType(rc).success() ) 81 #else 82 # define RT_SUCCESS_NP(rc) ( (int)(rc) >= VINF_SUCCESS ) 83 #endif 84 85 /** @def RT_FAILURE 86 * Check for failure, predicting unlikely. 87 * 88 * We don't expect in normal cases, that is the code path depending on this 89 * check is normally NOT taken. To prevent any prediction use RT_FAILURE_NP 90 * instead. 91 * 92 * @returns true if rc indicates failure. 93 * @returns false if rc indicates success. 94 * 95 * @param rc The iprt status code to test. 96 * 97 * @remarks Please structure your code to use the RT_SUCCESS() macro instead of 98 * RT_FAILURE() where possible, as that gives us a better shot at good 99 * code with the windows compilers. 100 */ 101 #define RT_FAILURE(rc) ( RT_UNLIKELY(!RT_SUCCESS_NP(rc)) ) 102 103 /** @def RT_FAILURE_NP 104 * Check for failure, no prediction. 105 * 106 * @returns true if rc indicates failure. 107 * @returns false if rc indicates success. 108 * 109 * @param rc The iprt status code to test. 110 */ 111 #define RT_FAILURE_NP(rc) ( !RT_SUCCESS_NP(rc) ) 112 38 113 39 114 #ifdef __cplusplus … … 110 185 #endif /* __cplusplus */ 111 186 112 113 /** @def RTERR_STRICT_RC114 * Indicates that RT_SUCCESS_NP, RT_SUCCESS, RT_FAILURE_NP and RT_FAILURE should115 * make type enforcing at compile time.116 *117 * @remarks Only define this for C++ code.118 */119 #if defined(__cplusplus) \120 && !defined(RTERR_STRICT_RC) \121 && !defined(RTERR_NO_STRICT_RC) \122 && ( defined(DOXYGEN_RUNNING) \123 || defined(DEBUG) \124 || defined(RT_STRICT) )125 # define RTERR_STRICT_RC 1126 #endif127 128 129 /** @def RT_SUCCESS130 * Check for success. We expect success in normal cases, that is the code path depending on131 * this check is normally taken. To prevent any prediction use RT_SUCCESS_NP instead.132 *133 * @returns true if rc indicates success.134 * @returns false if rc indicates failure.135 *136 * @param rc The iprt status code to test.137 */138 #define RT_SUCCESS(rc) ( RT_LIKELY(RT_SUCCESS_NP(rc)) )139 140 /** @def RT_SUCCESS_NP141 * Check for success. Don't predict the result.142 *143 * @returns true if rc indicates success.144 * @returns false if rc indicates failure.145 *146 * @param rc The iprt status code to test.147 */148 #ifdef RTERR_STRICT_RC149 # define RT_SUCCESS_NP(rc) ( RTErrStrictType(rc).success() )150 #else151 # define RT_SUCCESS_NP(rc) ( (int)(rc) >= VINF_SUCCESS )152 #endif153 154 /** @def RT_FAILURE155 * Check for failure, predicting unlikely.156 *157 * We don't expect in normal cases, that is the code path depending on this158 * check is normally NOT taken. To prevent any prediction use RT_FAILURE_NP159 * instead.160 *161 * @returns true if rc indicates failure.162 * @returns false if rc indicates success.163 *164 * @param rc The iprt status code to test.165 *166 * @remarks Please structure your code to use the RT_SUCCESS() macro instead of167 * RT_FAILURE() where possible, as that gives us a better shot at good168 * code with the windows compilers.169 */170 #define RT_FAILURE(rc) ( RT_UNLIKELY(!RT_SUCCESS_NP(rc)) )171 172 /** @def RT_FAILURE_NP173 * Check for failure, no prediction.174 *175 * @returns true if rc indicates failure.176 * @returns false if rc indicates success.177 *178 * @param rc The iprt status code to test.179 */180 #define RT_FAILURE_NP(rc) ( !RT_SUCCESS_NP(rc) )181 187 182 188 RT_C_DECLS_BEGIN
Note:
See TracChangeset
for help on using the changeset viewer.