Derive-C
Loading...
Searching...
No Matches
scope.h File Reference

Go to the source code of this file.

Macros

#define DC_SCOPED(type, ...)
 RAII in C. Call the destructor when the variable goes out of scope.
#define DC_DEFER(fcn)

Functions

 DC_ZERO_SIZED (sentinel)
 Simple zero sized value for DC_DEFER.

Macro Definition Documentation

◆ DC_DEFER

#define DC_DEFER ( fcn)
Value:
__attribute__((cleanup(fcn))) sentinel PRIV(NS(sentinel, __COUNTER__)) = {}
#define NS(pre, post)
Definition namespace.h:14
#define PRIV(name)
Definition namespace.h:20

Call the function with a null 'sentinel' value.

  • Useful for cleanup that does not take arguments

Definition at line 12 of file scope.h.

◆ DC_SCOPED

#define DC_SCOPED ( type,
... )
Value:
__attribute__((cleanup(type##_delete))) type __VA_ARGS__

RAII in C. Call the destructor when the variable goes out of scope.

Examples
container/arena.c, container/bitset.c, container/map.c, container/queue.c, container/set.c, container/vector.c, utils/option.c, utils/result.c, and utils/string_builder.c.

Definition at line 5 of file scope.h.

Function Documentation

◆ DC_ZERO_SIZED()

DC_ZERO_SIZED ( sentinel )

Simple zero sized value for DC_DEFER.