- 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
1.0f post !
Admin
Is it really that hard to turn off the warning? VC++ even gives you a nice 'pragma' line that you can use to turn off a specific warning, which you can put in the same header file you were going to put all that crap into.
Admin
Admin
abusing define is so 1980
Admin
Admin
This seems to be a "cousin" of a previous post (http://thedailywtf.com/Articles/His-Own-Way-to-Newline.aspx). What is truly adorable in these situations is, besides the "well thought" solution is the enthusiasm and passion these guys use to explain something totally abominable and sick. We all make mistakes, but being aware of a booboo you made seems to be less and less achievable.
Admin
You mean 1.00000081f post
Admin
The real WTF is that you're still using Visual Studio 6 when 8 is out and 9 is RTM'd. The upgrade is worth it, believe me. If your code is so broken it won't build with visual studio 8, then the problem is that your code is broken and not standards compliant, so it needs to be fixed.
If the problem is libraries that aren't controlled by you won't work properly with newer versions of visual studio, then bug the vendor about it. They probably have a newer version.
Admin
Keith seems to have missed the most important benefit of this scheme. If some other component of the system needs a different value for, say, 0.4, they need only:
#define OTHERCOMPONENT_P40 ((float) 0.40000001)
So each component can have its own value for 0.4. Can't do that with your 'f'.
Admin
Admin
This is a great idea! One should build a library with every single float constant in the world!
Admin
The real WTF is using floats when he clearly needs fixed point values.
... but that is so widespread that a lot of people probably consider it good practice :-(
Admin
as if there were not enough constants to remember, lol
Admin
HMI_TRUE is missing. And HMI_FALSE, HMI_FILE_NOT_FOUND and HMI_EOF. And of course HMI_ENDL. To avoid the nasty typos HMI_ENLD and HMI_ELND followed by HMI_FOUND_TON_FILE was added. Brilliant!
Admin
Legacy, my good man. Legacy.
Admin
What about the dreaded HMI_P333333333333333333333333333...?
Admin
#define HMI_P3bar (HMI_P10/HMI_P30)
should be manissalisous
Admin
Admin
Admin
I made it even better:
#define 1.1 1.1 #define 1.2 1.2
Admin
reading documentation is fun, but also takes a lot of time.
I mean, not everyone has the time to read up on the fact that macros can have arguments.
#define FLOAT(x) ((float) x)
Admin
I would like to up you one. Yours is too flexible and elegant. How about
#define HPI(x) (x ## f)
Isn't that much closer to the original in spirit?
Admin
I like how he used a c-style cast too.
Also, what's with the trailing zeroes on 1.30 and stuff.
Fire him.
Admin
In the 'real world' you don't just switch development platforms like that. The switch here from VC6 to VC7 took close to one man-month I'd say. In addition to updating all the code so it works on the new compiler (no small task), you need to change the install/upgrade code (runtime libraries and whatnot) and the build process.
And of course you still need the old compilers to support releases currently used in the field.
Admin
Impossible where I work. From <stdint.h> of our tool chain:
#define UINT32_C(value) ((uint_least32_t)(value))
Fortunately uint_least32_t and uint32_t are the same type. Probably they didn't have access to Gnu C library. Ironically, in our system using any of these macros causes a lint warning about unnecessary cast.
Admin
That should be #define FLOAT(x) ((float)(x))
Makes your C-code more LISP-like.
BTW, I prefer: #define FLOAT(x) x##F
Admin
This is an issue I deal with all the time. Option Strict might be a bit annoying, but its a life saver.
What annoys me to no end is when I write a constant expression and the compiler doesn't evaluate to see if it will fit. For example: dim u as uinteger = 1 dim i as integer = u+1 'unsigned int + signed int = signed long, compile error!
Admin
HMI_PAULA. Brillant!
Admin
I like the fact that someone carefully picked a few random numbers to turn to constants, like HMI_P07, HMI_P14 and specially HMI_P26
Admin
I actually said "what the f..." when I read the code.
Admin
the real wtf (tm) is obviously the c-family languages anyway.
you've got explicit typecasting, the weird trailing-letter after a numeric constant, and octal triggered by a leading zero to contend with.
Admin
Could HMI stand for "Human Machine Interface," and the various values given are the only valued allowed (detent positions) in the modelled system? Perhaps the code produces HMI instructions for otherwise MMI operations.
Admin
Seems like the nightmare of someone commenting a few articles back with code like char a() { char a='a'; return(a); } came true.
I seriously don't know how all the Computer Science department let all these morons out into the wild. I mean, one would think at least one teacher should have noticed.
Admin
But, there are many, many, CSS hacks advocates.
Admin
Admin
Admin
Ok, I'll admit:
unsigned int x = 0x3f800000; float *f = (float *)&x;
it was the (*f)'th post.
Admin
Admin
I have inherited a few hundred thousand lines of C and C++ code, which results in hundreds of lines like this:
because the [expletive deleted] consultants "didn't have time" to GO BACK and add the include string.h and other similar incredibly common directives. How many WTFs is that?
#1 What do you mean, "go back and add them"?? Why weren't they there in the first place?
#2 What do you mean, "I don't have time"?? How long does it take to cut and paste a few include directives into two or three dozen .C/.CXX files?
#3 What kind of programmer are you that you're "okay" with code that doesn't build cleanly? And don't give me that crap about how you "know" which warnings and errors can be safely ignored, you're just a lame slacker.
Admin
These comics are now the Daily WTF.
Admin
Yeah! And the brochure can proudly say how it is the "largest and most complete library in the world"! (Definitely the largest.)
Admin
I agree. C/C++ "Warnings" can be more serious than its Errors. I always use the GCC -Wall flag to verify code.
For example, an "implicit cast from incompatible pointer type" usually means a memory leak is ahead. If this is really what is needed, then write an explicit cast.
Admin
That's only until my constants library for type 'double' is released... It will be more accurate than your puny float library, and quite a bit larger as well.
I'm having some problems with typing it out though.
Admin
HMI_PI
?
Admin
Admin
Actually my comment was in favor of programmers who make a compiler that screams warnings if you don't include string.h and the "people who consider warnings" I was refering to are the ones who "don't have time to go back and add them"
Admin
mani- what? I googled for that word, and guess what I found?
Admin
Personally I can never understand why anyone would compile C as C, and not C++ but using fewer features. Changing the extension to .cpp costs nothing in speed and means you can use the free extra language features as appropriate - even if this is just the syntactic sugar and safer casting styles whilst ignoring the more complex features (virtual functions, templates, RTTI etc.).
Admin
Yeah, I can't understand that either. Now, if you'll excuse me, I need to go finish my current task: updating a program on a VAX 4000-700A running OpenVMS V6.2 using the DEC C++ version 5.6-013.
Admin
[quote user="MET"][quote user="mabinogi"] Personally I can never understand why anyone would compile C as C, and not C++ but using fewer features. Changing the extension to .cpp costs nothing in speed and means you can use the free extra language features as appropriate [...][/quote]
Because C++ is not a superset of C - they are two different languages. Yes, some C programs are valid C++ programs too, but certainly not all. Differences include treatment of void pointers and certain keywords that are no longer valid identifiers, C++ name mangling...