提交 09537592 编写于 作者: E Eric Blake 提交者: Jim Meyering

hacking: add a section on preprocessor conventions

* doc/hacking.html.in (preprocessor): New section to document
recently-discussed style issues.
Signed-off-by: NEric Blake <eblake@redhat.com>
上级 0be37833
...@@ -102,6 +102,20 @@ Usually they're in macro definitions or strings, and should be converted ...@@ -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.
......
...@@ -124,6 +124,25 @@ ...@@ -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 @@ ...@@ -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.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册