I am writing a Windows-specific library in C and am considering the use of try-finally
statements, a Microsoft extension to the C language, to streamline my code for cleaning up resources even in cases of unexpected failures. An example is given in Cleaning up resources.
I am not concerned about OS portability and with regard to compiler portability, the current version of Clang appears to support it on Windows as well.
The only negative consequence I have identified so far is potential interference with standard C++ exception handling. A detailed explanation of this can be found in the documentation pages Handle structured exceptions in C++ and /EH (Exception handling model). The situation seems safe for .NET languages, but I am concerned that C++ users may not set the right compiler option and possibly experience inconveniences like the one documented in this SO answer.
Is this a valid concern? Are there any other drawbacks or reasons to reconsider the use of try-finally
statements?