- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Time to get ill?
Admin
And since when does C have iostreams?
Oh great, which exactly are all those compiler suites that you are aware of? Let me guess, MSVC6, MSVC2005, MSVC2008? Sidenote: Borland or however it is called these days doesn't count in any way as their compilers are the biggest kitchen err bug sinks I am aware of. Sidenote2: Maybe check out GCC, ICC, Comeau, Sun Studio before saying "all compiler suites I am aware of". Sidenote3: This is actually about compiler and not suites.
Apart from anything but include guards being non-standard extensions.
Like the line that reads "cout<<YEAR<<"/"<<MONTH<<"/"<<DAYINMONTH; "? <BLOCKQUOTE class="Quote">I'll let my compiler inline for me where it thinks it's suitable. Most attempts to game the optimising passes of a decent compiler lose.
Admin
Nitpick: Actually, it's a call to one of std::ostream::operator<<'s.
Admin
FWIW, you CANNOT have unbalanced doublequotes in a macro... See "compilation stages" in ANSI C standard. With unbalanced doublequetes, tokenization will fail.
Admin
Admin
Unless I am missing something, the if guard is <=, and there is another one following it. So the last day of the month would show up as the first of the next month, but every other day would show up in the right month. this code just gets the month, not the entire date. Thus, I think only the last day of the last few months are affected.
On another note, why are they worried "when the system came CASHING to a halt"? It seems to me that a frozen system is still useful while spitting out money.
Admin
real wtf = "fix later" imo.
Admin
I don't know, but it made me come up with the concept of "orc code": code that was once fair and beautiful, but was tortured and mutilated into its now hideous form, so that now all you can do is kill it.
Admin
Admin
Is that really your first thought when you see a car crash? Do you work at a junk yard or something? My first would be "Does everyone look ok, or do I need to call 911?"
Admin
Nah. Time to get ugly. And yo momma's got a head start.
Admin
What is "911"?
Admin
Admin
They've got that penciled into the IMS for the 13th hour of the 13th day of the 13th month ("Lousy Smarch weather!").
Admin
As I pointed out above, I didn't notice the link to the full header and the article body doesn't make the distinction between C and C++. The inclusion of time.h rather than ctime suggested it was C (post the 1999 standard revisions).
I've never used MSVC, although I understand it's caught up with GCC and now offers "#pragma once" as well. I actually use GCC and Sun's compiler suite. Note that I say suite, because a compiler doesn't necessarily include a built in preprocessor - it's implementation dependent whether it's a part of the compiler, with a wrapper to call it on its own, or whether it really is implemented as a discrete application. Same for the linker, etc.
I was commenting about the need to make these inline at all rather than the correctness of the code as presented. I've seen way too much "inline disease" in C++ code, where large classes have their entire implementation defined as inline methods in a vain attempt to improve the performance of a fundamentally crap algorithm.
Admin
911 is the number for emergeny in USA. The operator can send the police, the fire department, an ambulance, or other first responders to any type of ermergency you have. They don't have people who handle WTFs.
Admin
Untested fix : http://paste2.org/p/252238
Admin
No, Samara is the russian city.
Admin
God damn it! Somebody beat me to the Smarch joke.
Oh well...
if (!COMMENT) { return FRIST; }
Admin
I thought Samara was the month that came after Sugust.
Admin
Admin
If you are in the role of training a newbie programmer, the hidden complexity of dates and times can be a good teaching tool.
You say to them, "hey, let's write code from scratch to handle some date math!" And later on, after they're driven half-mad from all the special cases they're code has to handle, open up some standard source code for time handling where it's all been written correctly. I promise you the student will have a much greater appreciation for "why re-invent the wheel" mentality after they've seen first hand how something which, naively, seems simple turns out to be incredibly painful when you have to handle all the special cases.
See also Small Matter Of Programming http://dictionary.reference.com/browse/SMOP
-- Furry cows moo and decompress.
Admin
Years ago, I worked for a company that had merged with another company back in the 1960's. It turned out that both companies had similar schemes for assigning customer numbers: basically two digit year that they entered this customer into the system plus a sequence number. So both companies had a customer 6000001, both had a 6000002, etc. This presented a problem for merging the data. So someone came up with a brilliant idea: Let's just add 20 to the year for the customers from the smaller company! We change 6000001 to 8000001, etc. Then we eliminate all the conflicts! Simple and effective solution.
I started there in 1980. Guess what was happening.
Of course, all the people who created this scheme had long since moved on.
Admin
"Incarnations"? Perhaps you meant "incantations"?
Admin
Sugest must be the Turkmenistan name for August. Gotta love dictators!
Admin
Admin
I hope Samara climbed out of Jared's television in a really creepy manner and offed him.
Admin
So I just fixed a data issue.
I was given some new code to maintain. Of course the guy wrote his own date libraries. AddOneDay, IsLeapYear, etc. Including a function to compare dates, title "CompareStartDate" and "LessThanOrEqualToEndDate" even though he might pass the start date to the end date.
The code worked by taking the date from the database in the form my mm-dd-yy, tokenizing it into three separate variables.
He passed the three variables to various functions, would combine them with dashes to print it out. Finally, the last step was to pass the variables on to another function, so he converted them to a datatime object and passed them on!
I ripped out all the code, converted the string coming from the database to a datetime, and left it in datetime format.
Admin
Admin
The first bug I had to fix when I entered our company was also a date problem. Somebody wrote wonderfull code like this 10 years ago:
If Right(DateValue,4)="1996" Or Right(DateValue,4)="2000" Or Right(DateValue,4)="2004" Or Right(DateValue,4)="2006" Then 'Do some work EndIf
Unfortunately this was a report over the last 3 years and today was January 2008 and this little bug caused the complete Access Report to crash and noone had an idea why this happened.
Admin
Tested a simple app in VC9 & G++4.2.3. Both fail if I define an int in a header w/ no include guard and include the header twice.
Compilers may cache the read, but they cannot necessarily cache the parse as preprocessor directives may different with each inclusion. Additionally, this behavior would be not compliant, to say the least.
Admin
Date/time parsing: Nature's Rubik's cube.
Admin
Thank you so much for taking time out of your spiny balls-filled life to educate us all on our deficiencies as single celled organisims.
Admin
Admin
Never mind. I just noticed the linked file wasn't the stdlib time.h and that the last function included cout.
He should have been using ctime
Admin
Admin
Humm, I don't know that song.
Admin
Looks like the junk an Indian outsourcing crew would write.
Admin
You might be a "Code Monkey" if adding lines such as
seems like a good idea. thank you, I'll be here till Febenary 42 (Sidereal time) JimAdmin
This code should look familiar to everyone here: it's got "my first function" written all over it.
Admin
I was hired because of nepotism, you insensitive clod!
Admin
And the correct answer is: Now.
Admin
And of course, you proposed to add 30 to the year for the customers of the bigger company. Smaller company continues uses number starting at 100 (or 00), and the other company numbers starting at 110 (or 10). Problem solved !
Admin
I assumed it was the month after Smarch.....
Admin
Call me stupid (no don't...) what does the bit in bold above mean???
Admin
If you really want the definitive response to the "is 2000 a leap year" question, you ought to quote the original Latin that was in the Pope's decree. It actually mentions the year "MM" by name (as being a leap year).
The year 2000 was specifically identified as a Leap Year by Pope Gregory XIII in his Papal Bull of February 24, 1582, Inter Gravissimas:
quote:
unquote:
Admin
If you look at the other comments before your one, you'll recognize that you are pretty astute :)
Admin
Anyone who doesn't use library functions for time/date should just leave the profession. Anytime you find yourself going down that route, ask yourself could there be a function to handle this? Chances are the answer's yes. So stop reinventing the wheel.
Admin
Using macros to implement functions is wtf.
We had a developer who wrote everything in macros. Nobody could debug or even read his code. When questioned, he claimed that "macros are fast". I guess he provided himself with some job security.
PS: Samara is one of the hubs in the USSR-built natural gas pipeline - Urengoi - Samara - Uzhgvorod. Or was it Pamary?
Admin
The code looks like it is written by someone who has never programmed before and read the first three chapters of "C for Dummies".