Re: Porting SANE backends

David Mosberger-Tang (David.Mosberger@acm.org)
Sun, 28 Feb 1999 13:10:01 -0800

>>>>> On Thu, 25 Feb 1999 20:34:35 +0100, Svend Daugaard Pedersen <sdp@vip.cybercity.dk> said:

Svend> - don't use 'alloca()' this routine is not an ANSI routine
Svend> and it is difficult (in many cases impossible) to implement
Svend> in a C system not having it.

No, alloca() is a sensible and well-defined operation. Shoot ANSI for
not making it standard. GNU C supports it on all platforms. And if
you don't use GNU C, you can use the portable implementation that
comes, e.g., with Emacs (look for alloca.c).

Svend> - don't use '#pragma' pragmas are completely implementation
Svend> dependant.

Agreed. I don't think there are any #pragma's in the SANE sources,
though.

Svend> - don't make any asumptions about the way variables are
Svend> stored in memory a special problem here is that INTEL
Svend> processors and M680xx processors stores words and long words
Svend> in a different way (use only arrays of SANE_Byte to transfer
Svend> data to or from the scanner). If you do not follow this
Svend> advice your code can't even be ported between Intel and 68K
Svend> Linux.

True, all SANE code should be byte-order independent.

Svend> - don't use special/unusual parameter values a call like
Svend> 'malloc(0)' is unlikely to be handled in the same way by all
Svend> compilers.

It's really the run-time system, but yes, there are differences even
between different UNIX versions.

--david

--
Source code, list archive, and docs: http://www.mostang.com/sane/
To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com