Closed ShujianQian closed 2 years ago
Hmm, two thoughts.
I'm certainly open to suggestion on this one, but because this is using macros, it's hard to resolve without resorting to things which are typically out of bounds.
I can definitely see your point there. I am following the convention commonly found in the Linux kernel and other C codebases. Here are some examples:
This issue seems to argue that name clashes with double underscores are rather uncommon.
Other options I can think of include:
CVEC_x
x___
I am in favor of either the prefix or underscore suffix solutions. Either one seems to reasonably avoid name collisions while avoiding what is technically undefined behavior.
I certainly understand that the linux kernel uses double underscores, but the kernel is so tightly coupled with the compiler that I think it is fair for them to use it. Redis... well, I would advise them not to do that ;-).
Anyway, If you update your PR to use any of the two suggested solutions, I'm happy to merge!
Sounds good! I changed the variable names to use a double underscore suffix.
Example of Shadowing Problem
With the original definition, the following code
would be expanded into
which is incorrect.
Changing
cv_cap
to__cv_cap
reduces the chance of such issues.