Hacker News new | past | comments | ask | show | jobs | submit login

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)




A 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.


That'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.


It'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?


Eclipse can colour or fold code within inactive preprocessor directives, but that may not be enough for this particular specimen.


Try to code it, test it, and submit your request. This is why we open source.


I looked at the spaghetti in your post and assumed it was a joke .. but then I looked at the real code :(




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: