How do I write an exception filter?

Ove Kaaven ovek at
Thu Jul 10 14:55:56 CDT 2008

Stefan Kuhr wrote:
> In include/wine/exception.h, a comment from AJ says that
> "__EXCEPT(filter_func,param)" is the proper way to do it but "param"
> is not explained at all

I think that comment must be very old, the macros don't implement any 

> So, how do I do these things in WINE properly?

In general, within Wine code, it's impossible. In standard C, a function 
cannot reference a local variable of another function. It might be 
possible with some trickery (e.g. declaring explicit register/volatile 
variables), or with special compiler support (MSVC obviously has special 
support for it, and perhaps gcc nested functions or something could be 

For Wine, you'd have to come up with something else. Whatever the filter 
function needs should be available in some other form than a stack 
variable, like maybe some global or thread-local (TLS) variable, or 
perhaps from some function call.

Also perhaps consider whether you need a filter function this complex at 

More information about the wine-devel mailing list