Hacker GitHub

← All repos

taeber/cwith

View on GitHub ↗ ★ 18 C

Automatic cleanup in C using with-statements

4 mentions on Hacker News by 1 person: 1 story, 3 comments · first 2020-05-31 · latest 2022-01-17

Mentions per year 4 mentions · busiest year 2020 (2)
20082026
  1. …\ { \ declare; \ if (( startup )) { \ do { \ block; \ } while(0); \ cleanup; \ } otherwise; \ } [1] https://github.com/taeber/cwith [2] https://github.com/taeber/cwith/blob/master/with.h
    comment by taeber · 2022-01-17 · in A simple defer feature for C
  2. …with (FILE *fp; fp = fopen(path, "wb"); fclose(fp)) { ... } else { perror("Failed to open file"); } https://github.com/taeber/cwith https://news.ycombinator.com/item?id=23370693 edit: formatting
    comment by taeber · 2022-01-16 · in A simple defer feature for C
  3. …construct. Another user was kind enough to even provide an example in their GitHub issue: https://github.com/taeber/cwith/issues/1 .