surround complex macros in ()
greg at kroah.com
Thu Aug 26 03:28:22 EDT 2021
On Wed, Aug 25, 2021 at 10:21:44PM -0700, daniel watson wrote:
> let me know if this is the right place to ask.
> i recently tried to make a commit adding parentheses around a macro
> it was rejected as "This is not a real change that is needed."
> at first, i thought this meant that the code would be identical with and
> without parentheses surrounding a complex macro's definition, when the
> macro is just typecasting an expression. but then i came up with code
> where having parens or not changes the meaning of the code.
> #define with ((int)a)
> #define sans (int)a
Note, this is NOT what your change was doing.
To duplicate what your change wanted to do, try doing:
#define with ((int)(10 * 20))
#define sans (int)(10 * 20)
Now see if that is any different when you use it.
More information about the Kernelnewbies