[libvirt] [PATCH 2/2] hacking: add a section on preprocessor conventions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>
---

This patch assumes that we are willing to mass-update preprocessor
indentation via Jim's cppi tool.

 HACKING              |   14 ++++++++++++++
 docs/hacking.html.in |   21 ++++++++++++++++++++-
 2 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/HACKING b/HACKING
index be8725d..4bc7b52 100644
--- a/HACKING
+++ b/HACKING
@@ -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.
diff --git a/docs/hacking.html.in b/docs/hacking.html.in
index 15029ac..8771c54 100644
--- a/docs/hacking.html.in
+++ b/docs/hacking.html.in
@@ -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.
-- 
1.6.6.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]