• (cs)

    DON'T_DELETE_THIS_COMMENT_PER_BOB

  • K (unregistered)

    #ifdef LAME_WTF

  • Blah (unregistered)

    #ifdef COMMENT_MODE WTF?? #endif

  • (cs)

    #ifdef Brillant wtf!? #endif

  • (cs)

    #ifdef TOO_MUCH_STUPIDITY

  • CaptainCaaaaaaaaveman (unregistered)

    #ifdef, you are lucky, not having to listen to more ifdefs.

  • Teemu (unregistered) in reply to snoofle
    #ifdef Brillant wtf!? #endif
    Shouldn't that be

    #ifdef wtf!? Brillant #endif

  • Bernie (unregistered)

    #ifdef MY_HEAD_EXPLODED_WITH_DARK_FOREBODINGS_TOO

  • Peter Burden (unregistered)

    I'm puzzled by the numbers that precede the #ifdef's.

    I can only assume that somebody has used grep (or similar) to extract all the #ifdef lines from some code and then sort and count. If so, why does "NOTDEFINED" appear twice?

    I wonder what the Makefiles looked like?

  • Mii (unregistered) in reply to Peter Burden
    Peter Burden:
    I'm puzzled by the numbers that precede the #ifdef's.

    I can only assume that somebody has used grep (or similar) to extract all the #ifdef lines from some code and then sort and count. If so, why does "NOTDEFINED" appear twice?

    I wonder what the Makefiles looked like?

    Maybe it's the count per file, not per occurence.

  • NOTDEFINED (unregistered)

    While

    #ifdef NOTDEFINED
    is certainly mind-boggling, one important macro is clearly missing:

    #ifdef FILE_NOT_FOUND
  • dave (unregistered)

    #ifdef SPAM_FILTER_OFF post loads of links #endif

  • (cs)

    My favorite:

    wtf:
    #ifdef TOO_MUCH_INFORMATION

    What happens if you leave this on? Does the system start going on and on about its colonoscopy or something?

  • badp (unregistered)
    #ifdef DO_NOT_USE
      return A_VERY_LONG_STRING_NOBODY_SHOULD_BE_USING_AND_IF_THEY_DO_OH_WELL
    #endif
  • (cs) in reply to Peter Burden
    Peter Burden:
    I can only assume that somebody has used grep (or similar) to extract all the #ifdef lines from some code and then sort and count. If so, why does "NOTDEFINED" appear twice?
    You can't see the trailing space in the second occurrence, but `sort` did.
  • RiX0R (unregistered) in reply to dpm
    dpm:
    Peter Burden:
    I can only assume that somebody has used grep (or similar) to extract all the #ifdef lines from some code and then sort and count. If so, why does "NOTDEFINED" appear twice?
    You can't see the trailing space in the second occurrence, but `sort` did.

    Actually, it's uniq. Just used this yesterday :).

  • CaRL (unregistered)
    Something gives Dave the idea that several of these #ifdefs shouldn't actually be used...
    No, according to the RFC, if you create an ifdef that should never be used, it should be called:

    #ifdef DO_NOT_USE

  • Eunich (unregistered) in reply to RiX0R
    RiX0R:
    Actually, it's `uniq`. Just used this yesterday :).
    Just yesterday? Not every day? Not yet already this morning?

    You must be one of those lusers who hasn't switched over to the uniqs operating system yet.

  • rick (unregistered)

    #ifdef OLDWAY

    because you can't trust CVS to retain older versions of anything.

  • Larry (unregistered)
    #ifdef BUG92283
    At first you'd think from the 5 digit bug number, this place has a lot of bugs.

    Next you'd think maybe not, because no other bug numbers appear in the list.

    Top coders however will recognize TRWTF. There should be ifdefs for every bug number.

    At my shop we use the ifdef bugno convention to comment out all buggy code. Then, a utility I wrote and only I truly understand combs through all the code looking for these ifdefs. I slurp up the lines of code inside the def into a massive hash. Then in a second pass I look for any recurrence of this known buggy code in any other locations. This guarantees that once a bug is identified, it will never be introduced again. Presto, no more regressions!

    (Patent pending.)

  • tycho (unregistered) in reply to RiX0R
    Actually, it's `uniq`. Just used this yesterday :).

    'sort -u' to reduce pipes, though I'm pretty sure this is GNU-specific.

  • MooseBrains (unregistered)

    We're always joking about adding bits to our codebase that read '

    if( "martinx".equals(user.getLoginName()) ) { ... }
    ', but... I mean... you just joke about stuff like that, right? Right?

    BTW, I hope Brut gets better soon.

  • myoh (unregistered)

    #ifdef MORBIUS_DOESNT_UNDERSTAND_LOGIC

  • Sleepy (unregistered)
    #ifdef SLEEP_DOESNT_WORK
      try {
        sex()
      }
      on exception {
        init 1
      }
    #endif
    
  • Machtyn (unregistered)

    Knock, knock.

    • Who's there? ifdef
    • ifdef who?

    Knock, knock.

    • Who's there? ifdef
    • ifdef who?

    Knock, knock.

    • Who's there? ifdef
    • ifdef who?

    Knock, knock.

    • Who's there? endif
    • endif who? Aren't you glad I ended this?

    captcha: plaga - may one be heaped upon this comment

  • the Dragon (unregistered)

    If those are from an sqr program, then they are actually very useful, even if the naming standard seems a bit inconsistent. If the values are defined elsewhere, then processing occurs based upon that definition.

  • opyate (unregistered) in reply to halcyon1234
    1 #ifdef OLDWAY

    ...yes, how we did it in the 50s!

  • opyate (unregistered) in reply to halcyon1234

    Ugh, the power of preview. This is what I meant to say:

    My favorite:
    wtf:
    #ifdef TOO_MUCH_INFORMATION
    

    What happens if you leave this on? Does the system start going on and on about its colonoscopy or something?

    1 #ifdef OLDWAY

    Then it will also tell you how they did it in the fifties ;-)

  • Peter Burden (unregistered) in reply to RiX0R

    Seeing that trailing space was a good spot, must clean my glasses. [Or was it a trailing TAB.]

    I think the code may have been something like

    grep "#ifdef" *.c | sort | uniq -c

  • Wade (unregistered) in reply to NOTDEFINED
    NOTDEFINED:
    While
    #ifdef NOTDEFINED
    is certainly mind-boggling, one important macro is clearly missing:
    #ifdef FILE_NOT_FOUND

    At least they didn't use:

    #ifndef NOT_DEFINED

    or my head might have exploded.

  • OLD_CODE (unregistered)

    Our application we littered with #ifdef OLD_CODE. Some people just don't trust source control.

    One day we tried compiling it with OLD_CODE defined. Someone hypothesised that the resulting application might become self-aware, but actually it just printed a compiler error:

    Error: this code must not be compiled with OLD_CODE defined
    
  • OLD_CODE (unregistered) in reply to OLD_CODE
    OLD_CODE:
    Our application we littered with #ifdef OLD_CODE.
    *was* littered
  • Rich (unregistered) in reply to dpm
    dpm:
    Peter Burden:
    I can only assume that somebody has used grep (or similar) to extract all the #ifdef lines from some code and then sort and count. If so, why does "NOTDEFINED" appear twice?
    You can't see the trailing space in the second occurrence, but `sort` did.

    The archetypical command for this would be:

    find . -type f | xargs grep SOMETHING | sort | uniq -c

    tokens in the pipes would be whitespace delimited, effectively skipping any 'trailing' whitespace. If anything, may be a difference between spacing on the left side, not right side.

    captcha: ullamcorper Hmm, that's the realWTF

  • <NULL> (unregistered)

    Can I use these names or are they copyrighted? Most of them are pretty good!

  • <NULL> (unregistered) in reply to Larry

    Top coders rock!

  • clm (unregistered)
    #ifdef NOTDEFINED <snip>

    ...though it would be interesting to compile a version with all of those macros defined just to see what you'd get.

    Me, I'm not so sure -- I'd be too afraid of what might happen if NOTDEFINED were ever defined.

  • The Sussman (unregistered)
    #ifdef FILE_NOT_FOUND
    #warning "Brillant!"
    #endif // FILE_NOT_FOUND
  • bobr (unregistered) in reply to halcyon1234

    Is this really a WTF?

    First of all, these #ifdefs don't look like they are in a single file. It looks like the output from grep from a collection of files.

    Second of all, surrounding code you wish to preserve but not delete with "#ifdef OBSOLETE" and "#endif // OBSOLETE" is a perfectly reasonable way of commenting something out.

    Now, obviously, this type of code commenting should be removed at some point, but again, there is no indication that the files in question are in production.

    I'm just sayin'.

    bobr

  • Dazed (unregistered) in reply to MooseBrains
    MooseBrains:
    We're always joking about adding bits to our codebase that read '
    if( "martinx".equals(user.getLoginName()) ) { ... }
    ', but... I mean... you just joke about stuff like that, right? Right?
    You wish. Two days ago I inherited an application that does just that. To make it worse, the code that is run for users A and B is a repeat of what was just run for everyone, which means I'm probably going to have to go looking for obscure function side effects ...
  • CoyneT (unregistered)
    #ifdef MAD_HATTER
       (new WhiteRabbit).run();
    #endif
    
  • (cs)

    What's wrong with just using "#if 0"?

  • (cs) in reply to OLD_CODE
    OLD_CODE:
    OLD_CODE:
    Our application we littered with #ifdef OLD_CODE.
    *was* littered
    Glad you clarified, I read that as "In our app, we littered it with #ifdef..." and was trying to think of some WTF reason you'd unnecessarily use them.
  • Val (unregistered) in reply to halcyon1234
    halcyon1234:
    My favorite:
    wtf:
    #ifdef TOO_MUCH_INFORMATION

    What happens if you leave this on? Does the system start going on and on about its colonoscopy or something?

    We all know, that information has a critical value, which reached, will convert it to mass in a chain reaction, throwing us back to the Stone Age. Even Ijon Tichy knew about it.

  • (cs)

    I was surprised not to see

    #ifndef NEEDS_MORE_COWBELL

  • SwedishChef (unregistered) in reply to tezoatlipoca
    tezoatlipoca:
    I was surprised not to see

    #ifndef NEEDS_MORE_COWBELL

    And you'd be doing yourself and everyone else a disservice if you didn't ifdef the hell out of this WTF

  • Maris (unregistered) in reply to halcyon1234

    Well, defining lowercase old might be a WTF too.

    #ifdef old
  • drachenstern (unregistered) in reply to Teemu
    Teemu:
    #ifdef Brillant wtf!? #endif
    Shouldn't that be

    #ifdef wtf!? Brillant #endif

    I would think it would be more appropriate as #ifdef PAULA_BEAN #define PAULA_BEAN IS_BRILLANT #endif

    And if you think that's TRWTF, you must not be thinking of it the way PB would likely have done things...

    As for debugging, sorry, I haven't had several months to debug...

  • (cs) in reply to tycho
    tycho:
    'sort -u' to reduce pipes, though I'm pretty sure this is GNU-specific.

    'sort -u' is handy, but it doesn't give you the counts... The only way I know of to get the counts is 'sort | uniq -c' (or if you're like me, and want the list ordered by frequency 'sort | uniq -c | sort -nr' is what you're after.)

    Rich:
    The archetypical command for this would be:
    find . -type f | xargs grep SOMETHING | sort | uniq -c
    tokens in the pipes would be whitespace delimited, effectively skipping any 'trailing' whitespace. If anything, may be a difference between spacing on the left side, not right side.

    There's no concept of delimited tokens in pipes, only in the printing/reading programs - find, grep, sort and uniq delimit records with newlines by default, while xargs delimits records by whitespace. (Sort also has a concept of fields within records, which it delimits by blank-to-non-blank transitions by default.)

    If something was delimited by whitespace, then no whitespace anywhere on the line would be seen, whether on the left or the right. (With the possible exception of field delimiters at the start/end of the record.)

    As previously pointed out, the most likely occurance is two lines of the form:

    #ifdef<Space>NOTDEFINED
    and
    #ifdef<Space>NOTDEFINED<Space>
    or
    #ifdef<Tab>NOTDEFINED
    which look the same to the reader, but are different as far as sort and uniq are concerned.

    Addendum (2008-12-10 18:12): Re: record separators: see also find -print0, xargs -0, grep -Z, sort -z and uniq -z, which make the record separator for each a null byte. (Less ambiguous in ASCII text which might contain embedded whitespace/newlines within records.)

  • PseudoNoise (unregistered)

    Guys, I'm 100% serious here -- this is indicative of a huge WTF, and I beg you to heed what I say.

    Given, lots of these look like ways to comment-out/remove code blocks; not awful, just sloppy that it didn't get cleaned up.

    But look at these: 1 #ifdef BUG92283 3 #ifdef DIRECTIO_ON 1 #ifdef HAS_NAMESPACES 1 #ifdef REAL_DELETE 1 #ifdef SLEEP_DOESNT_WORK 5 #ifdef USE_QUANTIFY 7 #ifdef USE_STDIO_FILE 1 #ifdef USE_TIME 1 #ifdef UTIL_GLOBAL

    That's 9 variations (that we know of!). If you make a change, you should test 2^9 variations and make sure they all work.

    Folks, this way lies madness. ONLY allow #ifdefs for:

    • header inclusion guard
    • NDEBUG as defined in C/C++ spec (e.g., with assert)
    • compiler-specific code
  • Dean (unregistered) in reply to Peter Burden

    I'm assuming most of those conditionals are used to comment code out. The usual convention is:

    #if 0 /* explanation of why it's disabled */

    #endif

    but #ifdef SOME_TOKEN_NOT_DEFINED achieves the same thing. Hence you wouldn't expect to see it in the Makefiles at all.

    It's redundant if you have and use version control, but plenty of people in non-preprocessed languages comment out blocks.

Leave a comment on “#ifdef WTF”

Log In or post as a guest

Replying to comment #:

« Return to Article