kopia lustrzana https://gitlab.com/sane-project/website
115 wiersze
4.3 KiB
HTML
115 wiersze
4.3 KiB
HTML
<!-- received="Sat Apr 4 16:50:21 1998 PST" -->
|
|
<!-- sent="Sat, 4 Apr 1998 16:50:19 -0800" -->
|
|
<!-- name="David Mosberger-Tang" -->
|
|
<!-- email="David.Mosberger@acm.org" -->
|
|
<!-- subject="coding guide" -->
|
|
<!-- id="199804050050.QAA09994@panda.mostang.com" -->
|
|
<!-- inreplyto="" -->
|
|
<title>sane-devel: coding guide</title>
|
|
<h1>coding guide</h1>
|
|
<b>David Mosberger-Tang</b> (<a href="mailto:David.Mosberger@acm.org"><i>David.Mosberger@acm.org</i></a>)<br>
|
|
<i>Sat, 4 Apr 1998 16:50:19 -0800</i>
|
|
<p>
|
|
<ul>
|
|
<li> <b>Messages sorted by:</b> <a href="date.html#52">[ date ]</a><a href="index.html#52">[ thread ]</a><a href="subject.html#52">[ subject ]</a><a href="author.html#52">[ author ]</a>
|
|
<!-- next="start" -->
|
|
<li> <b>Next message:</b> <a href="0053.html">Peter-Paul Witta: "Q: support for digi cameras"</a>
|
|
<li> <b>Previous message:</b> <a href="0051.html">David Mosberger-Tang: "Re: Mustek,"</a>
|
|
<!-- nextthread="start" -->
|
|
<!-- reply="end" -->
|
|
</ul>
|
|
<!-- body="start" -->
|
|
Hi everyone,<br>
|
|
<p>
|
|
I finally got tired of telling the same story over and over again, so<br>
|
|
I put together a short list of rules that should help keeping SANE<br>
|
|
portable and easy to maintain. I appended a copy below. Comments are<br>
|
|
welcome and additions too, though I don't want to have this degenerate<br>
|
|
into a long document that nobody wants to read...<br>
|
|
<p>
|
|
Cheers,<br>
|
|
<p>
|
|
--david<br>
|
|
<p>
|
|
--------------------------------------<br>
|
|
Sat Apr 4 16:22:00 1998<br>
|
|
<p>
|
|
Here are a few rules that should help writing a SANE-conformant<br>
|
|
backend:<br>
|
|
<p>
|
|
* Please follow the GNU coding standards. It's clear that the style<br>
|
|
outlined there is nobody's favorite, but it's much easier to<br>
|
|
maintain SANE if everybody follows more or less the same coding<br>
|
|
style. It also looks more professional. The GNU standards can be<br>
|
|
found at:<br>
|
|
<p>
|
|
<a href="http://www.gnu.org/prep/standards_toc.html">http://www.gnu.org/prep/standards_toc.html</a><br>
|
|
<a href="ftp://ftp.gnu.org/pub/gnu/standards/standards.text">ftp://ftp.gnu.org/pub/gnu/standards/standards.text</a><br>
|
|
<p>
|
|
Note that GNU emacs supports automatic indentation according to this<br>
|
|
standard. The command "indent -gnu" can be used to reformat<br>
|
|
existing sources according to this standard.<br>
|
|
<p>
|
|
* Please be curteous to programmer's with terminals that are 80<br>
|
|
characters wide. It's not difficult to avoid long lines, so please<br>
|
|
do so. Note that in ANSI C you can split long strings into pieces<br>
|
|
separated by white space. For example,<br>
|
|
"this is an awfully long string" can be written as "this is an "<br>
|
|
"awfully long string".<br>
|
|
<p>
|
|
* Please do not assume that `size_t' is `unsigned int'. On some<br>
|
|
systems, it's `unsigned long' and the size of this type may be<br>
|
|
bigger than that of an int (this is true for practially any of the<br>
|
|
64-bit systems). To print a variable of type size_t portably, cast<br>
|
|
the variable to u_long and print it with the %lu specifier. E.g.:<br>
|
|
<p>
|
|
size_t len;<br>
|
|
<p>
|
|
printf ("len=%lu\n", (u_long) len);<br>
|
|
<p>
|
|
* Please do not depend on GNU C specific features or, if you do, make<br>
|
|
the dependency conditional so other compilers will still be able to<br>
|
|
compile the files. In particular:<br>
|
|
<p>
|
|
- do not use C++ style comments (//-line comments)<br>
|
|
<p>
|
|
- do not declare dynamically sized automatic arrays; instead,<br>
|
|
use alloca() after including <lalloca.h>. For example:<br>
|
|
<p>
|
|
void<br>
|
|
func (int n)<br>
|
|
{<br>
|
|
char buf[n];<br>
|
|
}<br>
|
|
<p>
|
|
should be re-written as:<br>
|
|
<p>
|
|
#ifdef _AIX<br>
|
|
# include <lalloca.h> /* MUST come first for AIX! */<br>
|
|
#endif<br>
|
|
<p>
|
|
#include "sane/config.h"<br>
|
|
#include <lalloca.h><br>
|
|
:<br>
|
|
void<br>
|
|
func (int n)<br>
|
|
{<br>
|
|
char *buf = alloca (n);<br>
|
|
}<br>
|
|
<p>
|
|
<p>
|
|
<pre>
|
|
--
|
|
Source code, list archive, and docs: <a href="http://www.mostang.com/sane/">http://www.mostang.com/sane/</a>
|
|
To unsubscribe: echo unsubscribe sane-devel | mail <a href="mailto:majordomo@mostang.com">majordomo@mostang.com</a>
|
|
</pre>
|
|
<!-- body="end" -->
|
|
<p>
|
|
<ul>
|
|
<!-- next="start" -->
|
|
<li> <b>Next message:</b> <a href="0053.html">Peter-Paul Witta: "Q: support for digi cameras"</a>
|
|
<li> <b>Previous message:</b> <a href="0051.html">David Mosberger-Tang: "Re: Mustek,"</a>
|
|
<!-- nextthread="start" -->
|
|
<!-- reply="end" -->
|
|
</ul>
|