On Fri, Oct 04, 2019 at 02:26:26PM -0600, Jeff Law wrote: > Same objections as before. As long as we're using macros like this, > we're going to have increased potential for shadowing problems and > macros which touch implementation details that just happen to be > available in the context where the macro is used. > > Convert to real functions. It avoids the shadowing problem and avoids > macros touching/referencing things they shouldn't. Code in macros may > have been reasonable in the 80s/90s, but we should know better by now. > > I'm not ranting against you Bernd, it's more a rant against the original > coding style for GCC. Your changes just highlight how bad of an idea > this kind of macro usage really is. We should take the opportunity to > fix this stuff for real.
To get 95% of the benefit for only 2% of the pain, you can make an inline function where there was a macro before, and define that same macro to just call the function. Like #define DEFAULT_SOME_MACRO(PARMS) { lots of code } becomes #define DEFAULT_SOME_MACRO(PARMS) default_some_macro(PARMS) static inline int default_some_macro (int parm, long another) { lots of code; } The point is that all this is completely *local* changes. Segher