Derive-C
Loading...
Searching...
No Matches
bitset.c
Go to the documentation of this file.
1
4
5#include <derive-c/prelude.h>
6#include <stdio.h>
7
8#define EXCLUSIVE_END_INDEX 128
9#define NAME bitset
11
12static void example_basic() {
14 DC_SCOPED(bitset) bs = bitset_new();
15
16 bitset_set(&bs, 0, true);
17 bitset_set(&bs, 5, true);
18
19 bitset_debug(&bs, dc_debug_fmt_new(), stdout);
20
21 for (bitset_index_t i = 0; i < 128; i++) {
22 if (bitset_get(&bs, i)) {
23 printf("Bit at index %u is set\n", i);
24 }
25 }
26
27 DC_FOR_CONST(bitset, &bs, iter, index) { printf("Iterated index: %u\n", index); }
28}
29
30int main() {
32 return 0;
33}
static void example_basic()
Definition bitset.c:12
int main()
Definition bitset.c:30
static DC_PUBLIC dc_debug_fmt dc_debug_fmt_new()
Definition fmt.h:15
#define DC_FOR_CONST(TYPE, INSTANCE, ITER, ITEM)
Definition for.h:14
#define DC_SCOPED(type,...)
RAII in C. Call the destructor when the variable goes out of scope.
Definition scope.h:5
#define DC_DEBUG_TRACE
Definition debug.h:17