| « Prev | Page 1 | Page 2 | Next » |
|
DON'T_DELETE_THIS_COMMENT_PER_BOB
|
|
#ifdef COMMENT_MODE
WTF?? #endif |
|
#ifdef, you are lucky, not having to listen to more ifdefs.
|
Shouldn't that be #ifdef wtf!? Brillant #endif |
|
#ifdef MY_HEAD_EXPLODED_WITH_DARK_FOREBODINGS_TOO
|
|
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. |
|
While
#ifdef NOTDEFINEDis certainly mind-boggling, one important macro is clearly missing: #ifdef FILE_NOT_FOUND |
|
#ifdef SPAM_FILTER_OFF
post loads of links #endif |
|
My favorite:
What happens if you leave this on? Does the system start going on and on about its colonoscopy or something? |
#ifdef DO_NOT_USE |
You can't see the trailing space in the second occurrence, but `sort` did. |
Actually, it's `uniq`. Just used this yesterday :). |
No, according to the RFC, if you create an ifdef that should never be used, it should be called: #ifdef DO_NOT_USE |
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. |
|
#ifdef OLDWAY
because you can't trust CVS to retain older versions of anything. |
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.) |
'sort -u' to reduce pipes, though I'm pretty sure this is GNU-specific. |
|
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. |
|
#ifdef MORBIUS_DOESNT_UNDERSTAND_LOGIC
|
|
|
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 |
|
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.
|
...yes, how we did it in the 50s! |
|
Ugh, the power of preview. This is what I meant to say:
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)
|
|
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 |
At least they didn't use: #ifndef NOT_DEFINED or my head might have exploded. |
|
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 |
*was* littered |
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 |
|
Can I use these names or are they copyrighted? Most of them are pretty good!
|
|
Top coders rock!
|
Me, I'm not so sure -- I'd be too afraid of what might happen if NOTDEFINED were ever defined. |
#ifdef FILE_NOT_FOUND |
|
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 |
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 ... |
|
|
What's wrong with just using "#if 0"?
|
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. |
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. |
|
I was surprised not to see
#ifndef NEEDS_MORE_COWBELL |
Re: #ifdef WTF
2008-12-10 15:34
•
by
SwedishChef
(unregistered)
|
And you'd be doing yourself and everyone else a disservice if you didn't ifdef the hell out of this WTF |
|
Well, defining lowercase old might be a WTF too.
|
Re: #ifdef WTF
2008-12-10 17:55
•
by
drachenstern
(unregistered)
|
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... |
'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.)
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>NOTDEFINEDand #ifdef<Space>NOTDEFINED<Space>or #ifdef<Tab>NOTDEFINEDwhich 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.) |
|
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 |
|
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. |
| « Prev | Page 1 | Page 2 | Next » |