From: Eric Blake
Date: Tue, 9 Mar 2010 00:02:45 +0000 (-0700)
Subject: hacking: add a section on preprocessor conventions
X-Git-Tag: v0.8.0~328
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=095375925eced79b694e53a2e5fe13151e5e1378;p=thirdparty%2Flibvirt.git
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
---
diff --git a/HACKING b/HACKING
index b6f63ddac1..9ee87c1061 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 15029ac534..8771c54f97 100644
--- a/docs/hacking.html.in
+++ b/docs/hacking.html.in
@@ -124,6 +124,25 @@
+
+
+
+ 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
+
+
+
@@ -405,7 +424,7 @@
#include <limits.h>
#if HAVE_NUMACTL Some system includes aren't supported
- #include <numa.h> everywhere so need these #if defences.
+ # include <numa.h> everywhere so need these #if defences.
#endif
#include "internal.h" Include this first, after system includes.