simon-git: putty (main): Simon Tatham
Commits to Tartarus hosted VCS
tartarus-commits at lists.tartarus.org
Sun Nov 28 10:02:59 GMT 2021
TL;DR:
cbc723bf testcrypt-funcs.h: remove extra parens round argument lists.
Repository: https://git.tartarus.org/simon/putty.git
On the web: https://git.tartarus.org/?p=simon/putty.git
Branch updated: main
Committer: Simon Tatham <anakin at pobox.com>
Date: 2021-11-28 10:02:59
commit cbc723bf9daa9990981aca047c65420379effeb7
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=cbc723bf9daa9990981aca047c65420379effeb7;hp=44055cd36ef0ee7cf9b03d3ff6ec39e51bfa92b6
Author: Simon Tatham <anakin at pobox.com>
Date: Sun Nov 28 09:39:49 2021 +0000
testcrypt-funcs.h: remove extra parens round argument lists.
They were there to work around that annoying feature of VS's
preprocessor when it expands __VA_ARGS__ into the argument list of
another macro. But I've just thought of a workaround that I can apply
in testcrypt.c itself, so that those parens don't have to appear in
every function definition in the header file.
The trick is, instead of writing
destination_macro(__VA_ARGS__)
you instead write
JUXTAPOSE(destination_macro, (__VA_ARGS__))
where JUXTAPOSE is defined to be a macro that simply expands its two
arguments next to each other:
#define JUXTAPOSE(first, second) first second
This works because the arguments to JUXTAPOSE get macro-expanded
_before_ passing them to JUXTAPOSE itself - the same reason that the
standard tricks with STR_INNER and CAT_INNER work (as seen in defs.h
here). So this defuses the magic behaviour of commas expanded from
__VA_ARGS__, and causes the destination macro to get all its arguments
in the expected places again.
test/testcrypt-func.h | 780 ++++++++++++++++++++++++--------------------------
test/testcrypt.c | 103 +++----
test/testcrypt.py | 2 -
3 files changed, 422 insertions(+), 463 deletions(-)
More information about the tartarus-commits
mailing list