- 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
Success? Flail.
Admin
#define DEVELOPER FAILURE
Admin
#define OUTSOURCING FAILURE
Admin
#define FAILURE TRUE
Admin
They should at least check against EOF and FileNotFound.
Admin
#define OUTSOURCEDCODE WORSE_THAN_FAILURE
Admin
Admin
Nothing wrong with zero for success and non-zero for failure. That's the traditional Unix way. There's only one way for a function to succeed, and potentially many ways to fail, corresponding to the true/false semantics in C.
But judging from the rest of this wtf, I'm guessing that's not what motivated this "design".
Admin
#define FAILURE 1
I need a t-shirt with that on.
Admin
But in C, 0 is false and non-0 is true. You are implying the opposite, if I got you right (sorry if I didn't)
Admin
Every C/C++-program returns an integer value. 0 == success and everything else is the error code that occurred.
That's why you can write something like:
./configure && make && make install
The second and third command is only executed if the previous commands returned 0.
Admin
So for C, zero is false and non-zero is true. Zero is success and non-zero is failure. Those define's aren't really WTF's except for being defined twice.
Admin
Since no one else has said it, I will:
FILE_NOT_FOUND!
Admin
Admin
Admin
0 is false success 1 is true failure
Admin
C/C++ programs don't have to return an int.
Admin
In Unix, though, "return non-zero on failure" is very very common. Windows code seems to have half-absorbed this rul.e
Admin
Makes me wonder whether there are books in those outsource-to countries which teach these kinds of 'patterns' - because they seem to be pretty common down there.
Admin
#define OPER_SUCCESSFUL "SUCS"
Admin
Outsourcing to India sucks!
Guess who in future gonna clean-up the mess?
Admin
Fixed that for you.
Admin
SUCSESS is a marketing slogan of DonkeyVac, Inc.
Strange, there was a captcha but it turned into a werewolf and ran away...
Admin
Admin
Admin
Can sumeboody sent ma thier aderes, eye nede a jab.
P.S. does tham paid weel?
Admin
The last time I was in a position where I had to care about C or C++ standards, the ISO standards said that main must return int.
Every compiler in the world let you get away with void, but there was no requirement in the standard that the Deathstation 9000 would behave the same way.
It's entirely possible that void main() was introduced in the meantime as a C99-ism, making my perspective outdated; but if so I would consider it a shameful caving-in to pressure from the programming book authors that has been (incorrectly) teaching void main() since the 1980's.
Admin
#define GREAT_SUCSESS!
Admin
The "bool" type in C++ is not that hot, especially as it comes to STL. To paraphrase (badly) Scott Meyers, from one of the Effective books: There's nothing wrong with an STL collection of bool, so long as you understand it's not really a collection, and it doesn't really have bools in it.
C++ is a beautiful language; if you have a brilliant mind, it allows you to express things that most other languages can't hope to touch. It's also the idiots' power tool for creating WTFs. My favorite C++ WTF of all time:
#define private public #define protected public
That, is pain.
Admin
The standard still does. Even the latest C++0x draft, section 3.6.1.2:
Admin
Main must return int in C++.
Admin
I used to work for an outsourcing company before getting a real job, and this doesn't surprise me.
We didn't have source control or code reviews, the developers wrote the QA tests and carried them out, and we didn't have a bug tracking system (although one team leader introduced a system using sheets of paper, one for each bug, and folders named "OPEN", "ASSIGNED", "RESOLVED" etc).
Some code we developed for a major British Telecom company (which is now known by its initials) was a mail access layer. It worked fine for our developers and during QA. But the week before delivery one or our developers decided to take a look at what would happen if two or more users accessed their email simultaneously. There was, I believe, a null pointer dereference and the code crashed.
An emergency late night debugging session eventually revealed that account details were stored in a single global variable.
A couple of years later, when in general we actually knew a bit more about what we were doing, a project another team worked on was benchmarked an order of magnitude faster than any other similar application we tested ... with one user. Each additional sign on reduced performance by a half, ie. with five users performance was 1/16.
Admin
Looks to me like the mis-spelling "SUCSESS" might actually be deliberate, so that when you call Admin:Update() you can distinguish between OPER_SUCCESSFUL and actual success!
Admin
I'm fairly certain that my former employer once hired the same guy who wrote that... "User ID in a static variable on a web application? What's wrong with that?"
Admin
And in disbelief at the idiotic thing he had just done, I would say, "Why in god's name would you do something like that?"
And he would reply, "Because my employees will do it."
Yep, you don't want to be the tester of your own code. You're too intimate with it; you know what to do with it. It must be released to the idiots if it is to be idiot-proof.
Admin
const int TRUE = 1; const int FALSE = 0;
Works in any C99 compatible compiler and does away with annoying macro precedence problems, redefinitions, debugging problems, etc, etc.
captcha: genitus
Admin
Admin
#define FILE_NOT_FOUND 404
Admin
Contractors in China?
Admin
No. The point here, the point that gabba was making, is that C's true/false semantics are analogous to success/failure semantics, if truth is treated as equivalent to failure and falsehood is treated as equivalent to success.
As gabba said, there's only one way to succeed, but many ways to fail. And as you said, there's only one way to be false, but many ways to be true. Therefore, it makes sense for the single false value (zero) to map to the single success value, and for the many true values (anything with at least one bit set to 1) to map to the many failure values.
Admin
Then the code goes to QA, who should write their own tests and check across a wide range of platforms (assuming you're not going to deploy on a single target).
Admin
sucks cess.
Admin
The bad thing about defining FAILURE and TRUE to be the same value is that it lets you return TRUE or FALSE when you should be returning FAILURE or SUCCESS. If you're going to go through the hassle of defining your own custom return codes, why not create custom types, so that the compiler can check types for you, and make sure you're not about to shoot yourself in the foot.
Admin
Actually, the standard says that it returns EXIT_SUCCESS on success and EXIT_FAILURE on failure. What those values are is left up to the implementation. It is worth noting that they don't have to be zero and one. On Solaris and Unix the ones and zeros are switched, and I can never remember which one is which (hence why you are supposed to use the constants in stdlib.h )
I learned this from a C professor who insisted that anything we write for his class be portable onto both systems.
Admin
Admin
Admin
Yeah, SQL Server returns non-zero for its actual error codes. A zero is "woo-hoo! Your statement rocks!"
Admin
Nothing sucks seeds like sucsess.
Admin
Maybi hiz boss wantid to ahdopt a nu, mor lojicul speling ov wurds like sucsess?
Ouch! That was painful to type.
Admin
You're making that up.
For one thing, a return of 0 does have to be equivalent to a return of EXIT_SUCCESS, though EXIT_SUCCESS does not actually have to be defined as 0. For another thing, solaris is a unix variant, and in all unix variants (on unix systems, the C standard is not the only standard in play) and also on MS windows, EXIT_FAILURE is 1 and you are also allowed to return any value from 0 to 255 (greater values than 255 may be cut off to the last eight bits)