Closed dmitrylala closed 1 year ago
I had a similar problem, but only with VAR_NAME
. PROTO_TYPE
in this example is a class name, VAR_NAME
is a variable name, so in both these cases macros arguments must be valid string literals, or the program won't be compiled.
#define PROTO_TOSTRING(PROTO_TYPE, VAR_NAME) \ std::string PROTO_TYPE##ToString(const PROTO_TYPE & (VAR_NAME))
Macros like this obfuscate the code and make it difficult for understanding. Generally, we don't use macros that expand in unbalanced C/C++ constructs in our code. The Google C++ Style Guide gives an explanation why such macros should be avoided. I think you should drop the macros and define these functions properly.
https://github.com/tarantool/tarantool/actions/runs/3210914841/jobs/5249710180
checkpatch finds an error in macro: Macro argument 'PROTO_TYPE' may be better as '(PROTO_TYPE)' to avoid precedence issues
However, if i place PROTO_TYPE in parentheses, compilation error occurred, so I think it is a false positive.