3 ms·
Yup, C++ has autocleanup. Of course if you are using fopen() instead something more modern you'll need to fclose(). Adding a new keywords to C is a long shot.
by ape4 10y ago
Yup, C++ has autocleanup. Of course if you are using fopen() instead something more modern you'll need to fclose(). Adding a new keywords to C is a long shot. Perhaps compilers could detect non-cleanup use of goto and give it a warning.
- int_19h 10y agoA typical C++ codebase I'm working on these days would have scope guards implemented via macros, such that you can do e.g.: FILE* f = fopen(...); SCOPE_GUARD({ fclose(f); }); This is mainly used for one-off calls to some native API, where writing a proper RAII wrapper for the managed resource is not worth it.