1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-04 13:02:47 -05:00

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.
This commit is contained in:
Simon Tatham
2021-11-28 09:39:49 +00:00
parent 44055cd36e
commit cbc723bf9d
3 changed files with 422 additions and 463 deletions

View File

@ -354,7 +354,6 @@ def _parse_testcrypt_header(tokens):
expect(",", "after return type")
funcname = expect(is_id, "function name")
expect(",", "after function name")
expect("(", "to begin argument list")
args = []
firstargkind = expect({"ARG", "VOID"}, "at start of argument list")
if firstargkind == "VOID":
@ -373,7 +372,6 @@ def _parse_testcrypt_header(tokens):
if punct == ")":
break
expect("ARG", "to begin next argument")
expect(")", "at end of FUNC")
yield funcname, rettype, args
def _setup(scope):