FFmpeg 8.1
Loading...
Searching...
No Matches
Macros
avassert.h File Reference

simple assert() macros that are a bit more flexible than ISO C assert(). More...

#include <stdlib.h>
#include "attributes.h"
#include "log.h"
#include "macros.h"
#include "version.h"

Go to the source code of this file.

Macros

#define av_assert0(cond)
 assert() equivalent, that is always enabled.
 
#define av_assert1(cond)   ((void)0)
 assert() equivalent, that does not lie in speed critical code.
 
#define av_assert2(cond)   ((void)0)
 assert() equivalent, that does lie in speed critical code.
 
#define av_unreachable(msg)
 Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
 
#define av_assume(cond)   av_assert0(cond)
 

Detailed Description

simple assert() macros that are a bit more flexible than ISO C assert().

Author
Michael Niedermayer micha.nosp@m.elni.nosp@m.@gmx..nosp@m.at

Definition in file avassert.h.

Macro Definition Documentation

◆ av_assert0

#define av_assert0 (   cond)
Value:
do { \
if (!(cond)) { \
av_log(NULL, AV_LOG_PANIC, "Assertion %s failed at %s:%d\n", \
AV_STRINGIFY(cond), __FILE__, __LINE__); \
abort(); \
} \
} while (0)
#define AV_LOG_PANIC
Something went really wrong and we will crash now.
Definition log.h:197
#define AV_STRINGIFY(s)
Definition macros.h:66

assert() equivalent, that is always enabled.

Examples
mux.c, and transcode_aac.c.

Definition at line 42 of file avassert.h.

◆ av_assert1

#define av_assert1 (   cond)    ((void)0)

assert() equivalent, that does not lie in speed critical code.

These asserts() thus can be enabled without fearing speed loss.

Definition at line 58 of file avassert.h.

◆ av_assert2

#define av_assert2 (   cond)    ((void)0)

assert() equivalent, that does lie in speed critical code.

Definition at line 68 of file avassert.h.

◆ av_unreachable

#define av_unreachable (   msg)
Value:
do { \
av_log(NULL, AV_LOG_PANIC, \
"Reached supposedly unreachable code at %s:%d: %s\n", \
__FILE__, __LINE__, msg); \
abort(); \
} while (0)

Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.

Undefined behaviour occurs if execution reaches a point marked with av_unreachable() or if a condition used with av_assume() is false.

The condition used with av_assume() should not have side-effects and should be visible to the compiler.

Definition at line 99 of file avassert.h.

◆ av_assume

#define av_assume (   cond)    av_assert0(cond)

Definition at line 106 of file avassert.h.