Skip to content
Better HN
Top
Best
Ask
Show
New
Jobs
Search
⌘K
Go-style defer() implementation for C
(opens in new tab)
(github.com)
20 points
jagger11
8y ago
7 comments
Save
Share
7 comments
5 comments · 2 top-level
top
newest
oldest
ill0gicity
8y ago
· 2 in thread
I gathered two methods-- one for gcc, another for clang-- and crammed them into a set of macros that require no special compiler flags almost two years ago:
https://github.com/jeffwalter/defer/blob/master/include/defe...
jagger11
OP
8y ago
The clang code requires -fblocks/-lBlocksRuntime too, and I was a bit quicker :)
https://github.com/google/honggfuzz/commit/a9db9ddc2e24d157a...
ill0gicity
8y ago
I read your 2016 as 2017; guess that what being sick for a few days does to the brain. And it doesn't require you pass those options:
https://imgur.com/a/Hymj9
(clang-900.0.39.2)
1 more reply
iKlsR
8y ago
· 1 in thread
See also
https://oded.blog/2017/10/05/go-defer-in-cpp/
jagger11
OP
8y ago
Tho, in C++ I guess almost everybody would use a scoped variable with its desctructor using lambda.
j
/
k
navigate · click thread line to collapse