Home > Archive > VC Language > May 2006 > Another naming question: #define GET_LIBRARY_HANDLE_OR_RETURN(valu
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Another naming question: #define GET_LIBRARY_HANDLE_OR_RETURN(valu
|
|
| ultranet 2006-05-23, 7:11 pm |
| Any thoughts on this file-local macro?
#define GET_LIBRARY_HANDLE_OR_RETURN(value) \
jlong dynamicLibraryHandle = la_dee_dah_Component_getLibraryHandle(en
v,
obj); \
if (!dynamicLibraryHandle) return value;
The idea is to do something about the repetition of these 2 lines in
multiple methods.
Thanks.
| |
| Victor Bazarov 2006-05-23, 7:11 pm |
| ultranet wrote:
> Any thoughts on this file-local macro?
>
> #define GET_LIBRARY_HANDLE_OR_RETURN(value) \
> jlong dynamicLibraryHandle =
> la_dee_dah_Component_getLibraryHandle(en
v, obj); \
> if (!dynamicLibraryHandle) return value;
>
> The idea is to do something about the repetition of these 2 lines in
> multiple methods.
The only problem I have is the declaration of 'dynamicLibraryHandle',
which, if you place this macro twice in the same scope, will fail to
compile (multiple declaration).
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
| |
| Ulrich Eckhardt 2006-05-24, 4:16 am |
| ultranet wrote:
> Any thoughts on this file-local macro?
>
> #define GET_LIBRARY_HANDLE_OR_RETURN(value) \
> jlong dynamicLibraryHandle = la_dee_dah_Component_getLibraryHandle(en
v,
> obj); \
> if (!dynamicLibraryHandle) return value;
>
> The idea is to do something about the repetition of these 2 lines in
> multiple methods.
Create an object (somehow like a smart pointer) that retrieves the handle
and throws an assertion if not. This way you eliminate the returnvalue
(which can be used for useful stuff and not just error-reporting then) and
you make error handling mandatory.
Uli
|
|
|
|
|