diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-10-28 09:05:02 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-11-07 07:28:43 -0500 |
commit | 4541a590192a97d56c7a303492a2bc1bbeacb441 (patch) | |
tree | 07cd130cbde8c6a484e2f583d993b956ad7b5d5c /src/lib/cc/include.am | |
parent | 45698e89edecce71256bc5e2529f9610b0eea50f (diff) | |
download | tor-4541a590192a97d56c7a303492a2bc1bbeacb441.tar.gz tor-4541a590192a97d56c7a303492a2bc1bbeacb441.zip |
lib/cc: Define the standard C macro pasting trick in one place.
This file is a workaround for the issue that if you say `a ## b` to
create a token that is the name of a macro, the C preprocessor won't
expand that macro. So you can't say this:
#define FOO__SQUARE(x) ((x)*(x))
#define FOO__CUBE(x) ((x)*(x)*(x))
#define FOO(func, x) FOO__##func(x)
Instead, the standard C trick is to add a layer of indirection:
#define PASTE(a,b) PASTE__(a,b)
#define PASTE__(a,b) a ## b
#define FOO__SQUARE(x) ((x)*(x))
#define FOO__CUBE(x) ((x)*(x)*(x))
#define FOO(func, x) PASTE(FOO__, func)(x)
We should use this kind of trick sparingly, since it gets confusing.
Diffstat (limited to 'src/lib/cc/include.am')
-rw-r--r-- | src/lib/cc/include.am | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/lib/cc/include.am b/src/lib/cc/include.am index 1aa722dd82..d2a415e956 100644 --- a/src/lib/cc/include.am +++ b/src/lib/cc/include.am @@ -3,4 +3,5 @@ noinst_HEADERS += \ src/lib/cc/compat_compiler.h \ src/lib/cc/ctassert.h \ + src/lib/cc/tokpaste.h \ src/lib/cc/torint.h |