hacking: add a section on preprocessor conventions

* doc/hacking.html.in (preprocessor): New section to document
recently-discussed style issues.

Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Eric Blake 2010-03-08 17:02:45 -07:00 committed by Jim Meyering
parent 0be3783316
commit 095375925e
2 changed files with 34 additions and 1 deletions

14
HACKING
View File

@ -102,6 +102,20 @@ Usually they're in macro definitions or strings, and should be converted
anyhow.
Preprocessor
============
For variadic macros, stick with C99 syntax:
#define vshPrint(_ctl, ...) fprintf(stdout, __VA_ARGS__)
Use parenthesis when checking if a macro is defined, and use
indentation to track nesting:
#if defined(HAVE_POSIX_FALLOCATE) && !defined(HAVE_FALLOCATE)
# define fallocate(a,ignored,b,c) posix_fallocate(a,b,c)
#endif
C types
=======
Use the right type.

View File

@ -124,6 +124,25 @@
</p>
<h2><a href="types">Preprocessor</a></h2>
<p>
For variadic macros, stick with C99 syntax:
<pre>
#define vshPrint(_ctl, ...) fprintf(stdout, __VA_ARGS__)
</pre>
</p>
<p>Use parenthesis when checking if a macro is defined, and use
indentation to track nesting:
<pre>
#if defined(HAVE_POSIX_FALLOCATE) &amp;&amp; !defined(HAVE_FALLOCATE)
# define fallocate(a,ignored,b,c) posix_fallocate(a,b,c)
#endif
</pre>
</p>
<h2><a href="types">C types</a></h2>
<p>
@ -405,7 +424,7 @@
#include &lt;limits.h&gt;
#if HAVE_NUMACTL Some system includes aren't supported
#include &lt;numa.h&gt; everywhere so need these #if defences.
# include &lt;numa.h&gt; everywhere so need these #if defences.
#endif
#include "internal.h" Include this first, after system includes.