Derive-C
Loading...
Searching...
No Matches
readme.c File Reference

Go to the source code of this file.

Macros

#define CAPACITY   2048
#define NAME   alloc_2048
#define ITEM   char
#define ALLOC   alloc_2048
#define NAME   vec_char

Functions

static void example_readme (DC_LOGGER *parent)
int main ()

Macro Definition Documentation

◆ ALLOC

#define ALLOC   alloc_2048

Definition at line 8 of file readme.c.

◆ CAPACITY

#define CAPACITY   2048

Definition at line 3 of file readme.c.

◆ ITEM

#define ITEM   char

Definition at line 7 of file readme.c.

◆ NAME [1/2]

#define NAME   vec_char

Definition at line 4 of file readme.c.

◆ NAME [2/2]

#define NAME   alloc_2048

Definition at line 4 of file readme.c.

Function Documentation

◆ example_readme()

void example_readme ( DC_LOGGER * parent)
static

Definition at line 12 of file readme.c.

12 {
13 DC_SCOPED(DC_LOGGER) log = DC_LOGGER_NEW(parent, "%s", __func__);
14
15 alloc_2048_buffer buf;
16 alloc_2048 alloc = alloc_2048_new(&buf, stdalloc_get_ref());
17 vec_char vec = vec_char_new(&alloc);
18
19 DC_LOG(log, DC_INFO, "pushing digits 1-9");
20 for (char x = 1; x <= 9; x++) {
21 vec_char_push(&vec, (char)('0' + x));
22 }
23
24 vec_char_iter_const iter = vec_char_get_iter_const(&vec);
25 char const* entry;
26 while ((entry = vec_char_iter_const_next(&iter))) {
27 DC_LOG(log, DC_INFO, "entry: %c", *entry);
28 }
29
30 vec_char_delete(&vec);
31}
#define DC_LOGGER
Definition file.h:168
#define DC_SCOPED(type,...)
RAII in C. Call the destructor when the variable goes out of scope.
Definition scope.h:5
#define DC_LOGGER_NEW(...)
Definition prelude.h:21
#define DC_LOG(...)
Definition prelude.h:20
@ DC_INFO
Definition trait.h:8

◆ main()

int main ( )

Definition at line 33 of file readme.c.

33 {
35 root = NS(DC_LOGGER,
36 new_global)((NS(DC_LOGGER, global_config)){.stream = stdout, .ansi_colours = true},
37 (dc_log_id){"readme"});
38
39 example_readme(&root);
40 return 0;
41}
#define NS(pre, post)
Definition namespace.h:14
static void example_readme(DC_LOGGER *parent)
Definition readme.c:12