3 ms·
I'm a bit surprised that they have code like this: if (msec > 0 && ( # ifdef FEAT_XCLIPBOARD xterm_Shell != (Widget)0 # if defin
by Camillo 11y ago
I'm a bit surprised that they have code like this:
if (msec > 0 && (
# ifdef FEAT_XCLIPBOARD
xterm_Shell != (Widget)0
# if defined(USE_XSMP) || defined(FEAT_MZSCHEME)
||
# endif
# endif
# ifdef USE_XSMP
xsmp_icefd != -1
# ifdef FEAT_MZSCHEME
||
# endif
# endif
# ifdef FEAT_MZSCHEME
(mzthreads_allowed() && p_mzq > 0)
# endif
))
When they could have written:
if (msec > 0 && (
# ifdef FEAT_XCLIPBOARD
xterm_Shell != (Widget)0 ||
# endif
# ifdef USE_XSMP
xsmp_icefd != -1 ||
# endif
# ifdef FEAT_MZSCHEME
(mzthreads_allowed() && p_mzq > 0) ||
# endif
0))
Perhaps they were targeting compilers so primitive that they could not optimize out a "|| 0".
(edited to hide my shame)
- DSMan195276 11y agoA slight nit-pick, though I was going to say the exact same thing - `|| 0`. If you do `|| 1` the compiler's going to optimize the entire 'or' expression out ;) I was thinking that using `0` would cause a problem when you select none of those compilation options, but then I realize the code won't even compile if you don't select at-least one (You get empty parenthesis fallowing the '&&' in the 'if' statement), so it doesn't seem like a big deal.
- Camillo 11y agoThat's not a slight nit-pick, that's me being an idiot. I'm going to delete my account and travel the world barefoot for two years as penance.
- CephalopodMD 11y agoTry to code it, test it, and submit your request. This is why we open source.
- rasz_pl 11y agoI looked at the spaghetti in your post and assumed it was a joke .. but then I looked at the real code :(
- firebones 11y agoIt's been a long time since I've done bare C, but are there now IDEs/editors that let you toggle the define statements you want to activate which then format the code without the ifdef/endif cruft to let you better conceptualize the actual source?
- cardinalfang 11y agoEclipse can colour or fold code within inactive preprocessor directives, but that may not be enough for this particular specimen.