aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-01-10 10:30:52 -0500
committerNick Mathewson <nickm@torproject.org>2019-03-25 16:35:33 -0400
commit56bda7464f372d65d5564784266320994f605e1c (patch)
treedd38f1a9d344e79fb253c40bb476da63ddc44ee7 /src
parent0944500a8e2651854c948e91c178ac2a57c8ae41 (diff)
downloadtor-56bda7464f372d65d5564784266320994f605e1c.tar.gz
tor-56bda7464f372d65d5564784266320994f605e1c.zip
Add a macro for the fairly common "eat next semicolon" syntax trick
You use this when you're defining a macro to be used at file scope, and you want to require a semicolon afterwards.
Diffstat (limited to 'src')
-rw-r--r--src/lib/cc/compat_compiler.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/cc/compat_compiler.h b/src/lib/cc/compat_compiler.h
index d45316b241..83fa5dc33c 100644
--- a/src/lib/cc/compat_compiler.h
+++ b/src/lib/cc/compat_compiler.h
@@ -217,4 +217,16 @@
/** Macro: Yields the number of elements in array x. */
#define ARRAY_LENGTH(x) ((sizeof(x)) / sizeof(x[0]))
+/**
+ * "Eat" a semicolon that somebody puts at the end of a top-level macro.
+ *
+ * Frequently, we want to declare a macro that people will use at file scope,
+ * and we want to allow people to put a semicolon after the macro.
+ *
+ * This declaration of a struct can be repeated any number of times, and takes
+ * a trailing semicolon afterwards.
+ **/
+#define EAT_SEMICOLON \
+ struct dummy_semicolon_eater__
+
#endif /* !defined(TOR_COMPAT_H) */