[sane-devel] [SANE2 proposal] Error handling

Andi McLean andi.mclean at ntlworld.com
Sat Nov 29 16:49:10 GMT 2003


On Sat, 2003-11-29 at 16:23, Julien BLACHE wrote:
> Andi McLean <andi.mclean at ntlworld.com> wrote:
> 
> Hi,
> 
> > Why not combine the two e.g.
> >
> > typedef SANE_Status
> > {
> >   int code;
> >   int backend_code;
> > } SANE_Status;
> 
> That's another possibility, but given the way the SANE status codes
> are defined at the moment, they could share a 32 bit integer with a
> backend-specific status code without any problem. So let's spare some
> memory ;)
> 

> > You could always use a short instead of an int, which is almost the same
> > as proposal 2, but easier to access (No nasty bit manipulation)
> 
> That'd only require simple macros to build and use the SANE_Status
> returned, it's not that nasty or difficult imho ;)
> 
Personally I don't like using macros as they are not type safe, and can
cause problems when porting to other languages.
If you want to save memory (4 bytes :) ) then use 
typedef SANE_Status
{
  short code;
  short backend-code;
} SANE_Status;
which is still 32 bits long.

Andi :)
> JB.
> 
> -- 
> Julien BLACHE                                   <http://www.jblache.org> 
> <jb at jblache.org> 





More information about the sane-devel mailing list