From: Lino Sanfilippo > Sent: 04 November 2016 20:07 ... > In this case it is IMHO rather the declaration + initialization that makes > "bar" hard to find at one glance, not the use of RXT. You could do something > like > > [longish list of reverse xmas tree identifiers...] > struct foobarbaz *qux; > struct foo *bar; > > bar = longish_function(args, ...); > > to increase readability. > > Personally I find it more readable to always use a separate line for > initializations > by means of functions (regardless of whether the RXT scheme is used or not).
I find it best to only use initialisers for 'variables' that are (mostly) constant. If something need to be set to NULL in case a search fails, set it to NULL just before the loop. Don't put initialisation on the declaration 'because you can'. Difficulty in spotting the type of a variable is why (IMHO) you should but all declarations at the top of a function (except, maybe, temporaries needed for a few lines). David