Bah. Forgot to remove html.
On Fri, Dec 13, 2013 at 2:47 PM, Diego Novillo <dnovi...@google.com> wrote: > > > > On Wed, Dec 11, 2013 at 10:03 AM, Prathamesh Kulkarni > <bilbotheelffri...@gmail.com> wrote: >> >> I was wondering if it was a good idea to replace do-while macros with >> static inline functions returning void, where appropriate ? >> By "where appropriate" I mean: >> a) call to macro contains no side-effects >> b) macro does not modify the arguments. >> c) macro does not use any preprocessor operators (like ##) >> d) macro does not get undefined or is conditionally defined. >> e) macro is not type independent (use inline template for these?) >> f) Any other case ? >> >> Example: >> Consider C_EXPR_APPEND macro defined in c-tree.h: >> >> /* Append a new c_expr_t element to V. */ >> #define C_EXPR_APPEND(V, ELEM) \ >> do { \ >> c_expr_t __elem = (ELEM); \ >> vec_safe_push (V, __elem); \ >> } while (0) >> > > Yes, it's a good idea. One thing you will likely need to do, however, is to > add some of the replaced functions into gdb's list of ignored inline > functions. Some folks are used to gdb stepping over macro calls when 's' is > used. > > Not all macros need to be turned into functions. Some can be completely > removed (Trevor mentions an example in his reply). > > > Diego.