libcamera: log: Add an ASSERT macro
The ASSERT() macro is similar to the assert() macro defined by the C standard, but uses the libcamera logging infrastructure. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
@@ -36,6 +36,15 @@ private:
|
||||
|
||||
#define LOG(severity) LogMessage(__FILE__, __LINE__, Log##severity).stream()
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define ASSERT(condition) static_cast<void>(({ \
|
||||
if (!(condition)) \
|
||||
LOG(Fatal) << "assertion \"" #condition "\" failed"; \
|
||||
}))
|
||||
#else
|
||||
#define ASSERT(condition) static_cast<void>(false && (condition))
|
||||
#endif
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
||||
#endif /* __LIBCAMERA_LOG_H__ */
|
||||
|
||||
Reference in New Issue
Block a user