Files
react-native/ReactCommon/react/debug/react_native_assert.h
T
Joshua Gross d93b7c3369 Rename rn_assert to react_native_assert
Summary:
Keep consistent branding of rn -> react_native

Changelog: [Internal]

Reviewed By: fkgozali, mdvacca

Differential Revision: D26517069

fbshipit-source-id: 32fd3e52ee91e7ae72b6022535cb99ffc5b12303
2021-02-18 14:31:57 -08:00

51 lines
1.1 KiB
C

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// No header guards since it is legitimately possible to include this file more
// than once with and without RN_DEBUG.
// react_native_assert allows us to opt-in to specific asserts on Android and
// test before moving on. When all issues have been found, maybe we can use
// `UNDEBUG` flag to disable NDEBUG in debug builds on Android.
#include "flags.h"
#undef react_native_assert
#ifndef RN_DEBUG
#define react_native_assert(e) ((void)0)
#else // RN_DEBUG
#ifdef __ANDROID__
#include <android/log.h>
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
void react_native_assert_fail(
const char *func,
const char *file,
int line,
const char *expr);
#ifdef __cplusplus
}
#endif // __cpusplus
#define react_native_assert(e) \
((e) ? (void)0 : react_native_assert_fail(__func__, __FILE__, __LINE__, #e))
#else // __ANDROID__
#define react_native_assert(e) assert(e)
#endif // platforms besides __ANDROID__
#endif // NDEBUG