openexr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Openexr-devel] Exceptions in the DLL


From: Paul Nolan
Subject: Re: [Openexr-devel] Exceptions in the DLL
Date: Sun, 21 Nov 2004 17:48 +0000 (Pacific Standard Time)

> C++ exceptions are OpenEXR's mechanism for reporting errors.  If you're 
> using the library inside an application with a different error handling 
> mechanism, you should put a try/catch around calls you make to the 
> library, and map the exceptions into your own error code/class.  The 
> OpenEXR library should only throw exception classes that inherit from 
> Iex::Exception, which itself inherits from std::exception.

>From what I have read you can only do this if you can guarantee that the 
calling program uses the same compiler revision, compile flags, and 
standard library version.  There is an article by Herb Sutter in this 
months CUG (Dec 04) on the subject that  provides guidelines for creating 
C++ DLLs, his suggestions are to put catch(...) all around externally 
accessible functions, and return error codes instead, plus do not allow 
the calling program to free memory allocated in the DLL, and avoid user 
defined types in externally accessible interfaces.  I would recommend 
either doing this, or adding a big WARNING.TXT file to the directory that 
states what it is safe to use it with, or removing the precompiled DLLs 
all together, as someone might try using them on either a newer or older 
compiler, and not immediately notice problems.

> Or, are you talking about the C interfaces?  Those shouldn't be 
> propagating C++ exceptions, obviously.  Let me know if that's the case.

It looks like it at first glance, ImfOpenInputFile appears to be throwing 
a wobbly when given a non EXR file.  Hard to say for sure with this 
compiler as it doesn't give much info.

Thanks,

Paul Nolan, CEO Idruna Software Inc.
http://www.idruna.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]