1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

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. 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 C types
======= =======
Use the right type. Use the right type.

View File

@ -124,6 +124,25 @@
</p> </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> <h2><a href="types">C types</a></h2>
<p> <p>
@ -405,7 +424,7 @@
#include &lt;limits.h&gt; #include &lt;limits.h&gt;
#if HAVE_NUMACTL Some system includes aren't supported #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 #endif
#include "internal.h" Include this first, after system includes. #include "internal.h" Include this first, after system includes.