Author: AlAl
Date: Apr 21, 2008 11:19
Hi there,
I haven't kept up with the latest C best practices. In adapting
(wrapping, mostly) a C++ API which throws on error, which of these might
the better alternative, or are there other options I haven't considered?
/* Assume: */
typedef struct { ... } Error;
struct Foo;
/* Parametric (stateless) version: */
Foo* CreateFoo (int ctorparam, Error *const error);
bool PrintFoo (const Foo *const foo, Error *const error);
bool ReleaseFoo(const Foo *const foo, Error *const error);
/* Static (stateful) version: */
Foo* CreateFoo (int ctorparam);
bool PrintFoo (const Foo *const foo);
bool ReleaseFoo(const Foo *const foo);
Error* LastError ();
|