Comment On #ifdef WTF

Something gives Dave the idea that several of these #ifdefs shouldn't actually be used... [expand full text]
« PrevPage 1 | Page 2Next »

Re: #ifdef WTF

2008-12-10 08:03 • by amischiefr
DON'T_DELETE_THIS_COMMENT_PER_BOB

Re: #ifdef WTF

2008-12-10 08:06 • by K (unregistered)
#ifdef LAME_WTF

Re: #ifdef WTF

2008-12-10 08:18 • by Blah (unregistered)
#ifdef COMMENT_MODE
WTF??
#endif

Re: #ifdef WTF

2008-12-10 08:23 • by snoofle
#ifdef Brillant
wtf!?
#endif

Re: #ifdef WTF

2008-12-10 08:23 • by Smash King
#ifdef TOO_MUCH_STUPIDITY

Re: #ifdef WTF

2008-12-10 08:30 • by CaptainCaaaaaaaaveman (unregistered)
#ifdef, you are lucky, not having to listen to more ifdefs.

Re: #ifdef WTF

2008-12-10 08:32 • by Teemu (unregistered)
233859 in reply to 233854

#ifdef Brillant
wtf!?
#endif

Shouldn't that be

#ifdef wtf!?
Brillant
#endif

Re: #ifdef WTF

2008-12-10 08:33 • by Bernie (unregistered)
#ifdef MY_HEAD_EXPLODED_WITH_DARK_FOREBODINGS_TOO

Re: #ifdef WTF

2008-12-10 08:33 • by 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?

Re: #ifdef WTF

2008-12-10 08:37 • by Mii (unregistered)
233863 in reply to 233862
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.

Re: #ifdef WTF

2008-12-10 08:45 • by NOTDEFINED (unregistered)
While
#ifdef NOTDEFINED
is certainly mind-boggling, one important macro is clearly missing:
#ifdef FILE_NOT_FOUND

Re: #ifdef WTF

2008-12-10 08:47 • by dave (unregistered)
#ifdef SPAM_FILTER_OFF
post loads of links
#endif

Re: #ifdef WTF

2008-12-10 08:52 • by 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?

Re: #ifdef WTF

2008-12-10 08:54 • by badp (unregistered)
#ifdef DO_NOT_USE

return A_VERY_LONG_STRING_NOBODY_SHOULD_BE_USING_AND_IF_THEY_DO_OH_WELL
#endif

Re: #ifdef WTF

2008-12-10 09:17 • by dpm
233876 in reply to 233862
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.

Re: #ifdef WTF

2008-12-10 09:20 • by RiX0R (unregistered)
233877 in reply to 233876
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 :).

Re: #ifdef WTF

2008-12-10 09:21 • by 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

Re: #ifdef WTF

2008-12-10 09:23 • by Eunich (unregistered)
233879 in reply to 233877
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.

Re: #ifdef WTF

2008-12-10 09:26 • by rick (unregistered)
#ifdef OLDWAY

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

Re: #ifdef WTF

2008-12-10 09:35 • by 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.)

Re: #ifdef WTF

2008-12-10 09:39 • by tycho (unregistered)
233882 in reply to 233877
Actually, it's `uniq`. Just used this yesterday :).


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

Re: #ifdef WTF

2008-12-10 09:39 • by 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.

Re: #ifdef WTF

2008-12-10 09:40 • by myoh (unregistered)
#ifdef MORBIUS_DOESNT_UNDERSTAND_LOGIC

Re: #ifdef WTF

2008-12-10 09:40 • by Sleepy (unregistered)

#ifdef SLEEP_DOESNT_WORK
try {
sex()
}
on exception {
init 1
}
#endif

Re: #ifdef WTF

2008-12-10 09:55 • by 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

Re: #ifdef WTF

2008-12-10 09:57 • by 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.

Re: #ifdef WTF

2008-12-10 10:13 • by opyate (unregistered)
233896 in reply to 233871

1 #ifdef OLDWAY


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

Re: #ifdef WTF

2008-12-10 10:20 • by opyate (unregistered)
233897 in reply to 233871
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 ;-)

Re: #ifdef WTF

2008-12-10 10:20 • by Peter Burden (unregistered)
233898 in reply to 233877
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

Re: #ifdef WTF

2008-12-10 10:39 • by Wade (unregistered)
233900 in reply to 233868
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.

Re: #ifdef WTF

2008-12-10 10:44 • by 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

Re: #ifdef WTF

2008-12-10 10:52 • by OLD_CODE (unregistered)
233904 in reply to 233902
OLD_CODE:
Our application we littered with #ifdef OLD_CODE.

*was* littered

Re: #ifdef WTF

2008-12-10 10:56 • by Rich (unregistered)
233906 in reply to 233876
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

Re: #ifdef WTF

2008-12-10 11:05 • by <NULL> (unregistered)
Can I use these names or are they copyrighted? Most of them are pretty good!

Re: #ifdef WTF

2008-12-10 11:06 • by <NULL> (unregistered)
233909 in reply to 233881
Top coders rock!

Re: #ifdef WTF

2008-12-10 11:07 • by 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.

Re: #ifdef WTF

2008-12-10 11:30 • by The Sussman (unregistered)
#ifdef FILE_NOT_FOUND

#warning "Brillant!"
#endif // FILE_NOT_FOUND

Re: #ifdef WTF

2008-12-10 11:38 • by bobr (unregistered)
233928 in reply to 233871
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

Re: #ifdef WTF

2008-12-10 12:08 • by Dazed (unregistered)
233947 in reply to 233883
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 ...

Re: #ifdef WTF

2008-12-10 12:35 • by CoyneT (unregistered)

#ifdef MAD_HATTER
(new WhiteRabbit).run();
#endif

Re: #ifdef WTF

2008-12-10 13:08 • by jspenguin
What's wrong with just using "#if 0"?

Re: #ifdef WTF

2008-12-10 13:25 • by Bummer_Dude
233983 in reply to 233904
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.

Re: #ifdef WTF

2008-12-10 15:08 • by Val (unregistered)
234012 in reply to 233871
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.

Re: #ifdef WTF

2008-12-10 15:10 • by tezoatlipoca
I was surprised not to see

#ifndef NEEDS_MORE_COWBELL

Re: #ifdef WTF

2008-12-10 15:34 • by SwedishChef (unregistered)
234021 in reply to 234013
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

Re: #ifdef WTF

2008-12-10 17:14 • by Maris (unregistered)
234033 in reply to 233871
Well, defining lowercase old might be a WTF too.


#ifdef old

Re: #ifdef WTF

2008-12-10 17:55 • by drachenstern (unregistered)
234040 in reply to 233859
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...

Re: #ifdef WTF

2008-12-10 18:05 • by random_garbage
234043 in reply to 233882
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.)

Re: #ifdef WTF

2008-12-10 21:18 • by 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

Re: #ifdef WTF

2008-12-10 22:27 • by Dean (unregistered)
234067 in reply to 233862
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.
« PrevPage 1 | Page 2Next »

Add Comment