• xlq (unregistered)

    Oops, I messed up the [quote] tag.

  • Zylon (cs)

    It used to be common to do something very much like this in the old 8-bit Atari BASIC, though for completely different reasons.

    In that version of BASIC, all numbers were floats and took six bytes to store. But variables only took two bytes. So if you were really crunched for memory, you'd convert all your most-common numeric literals to variables and use those instead. So your program would start with someting like:

    10 N0=0:N1=1:N2=N1+N1:N3=N2+N1:N10=10:N256=256

    You could easily free up a kilobyte or more this way, which was significant when you only had 32 of them to play with!

  • Corona688 (cs) in reply to Beeblebrox
    Beeblebrox:
    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 your code won't build in visual studio, it's not standards compliant".

    That is awesome and terrible.

    Thank you, sir. You've just made my day.

    Visual Studio 6 is the only version that doesn't insert .net dependencies whether you're using them or not.

  • Ben (unregistered) in reply to Corona688

    BS. We used 7.1 (and now 8) to produce c++ code that ran fine on vanilla Win98 boxes.

  • jhamby (unregistered) in reply to dpm
    dpm:
    MET:
    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.).

    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.

    OMG, didn't you know they're up to V7.3 of the compilers now?

     Welcome to OpenVMS (TM) Alpha Operating System, Version V8.3    
        Last interactive login on Tuesday, 19-FEB-2008 10:06:16.70
        Last non-interactive login on Monday, 18-FEB-2008 02:27:37.40
    $ cc/version
    HP C V7.3-009 on OpenVMS Alpha V8.3
    $ cxx/version
    HP C++ V7.3-009 for OpenVMS Alpha V8.3
    Get with the times, man! :-)

    BTW, what's with the extra newlines when I use the code tag? It kind of defeats the purpose of the tag, unless I'm not using it right, or the bug is only in preview? At least in this case it makes it a little easier to read...

  • jhamby (unregistered) in reply to jhamby

    Oops, my bad, the latest VAX C++ compiler is V5.6C.

  • phaedrus (cs) in reply to Ferd
    Ferd:
    HMI_PI

    ?

    #define HMI_PI (float)3.0F // I Kings 7:23

  • SteveOC (unregistered)

    When I tried the example, I get a compiler warning :

    WARNING: HMI_WTF undefined

  • rednek (unregistered) in reply to dpm

    couldnt have said it better with a sharpened axe and a sledgehammer. Laziness is an excuse, no a disguise for incompetence

  • real_aardvark (cs) in reply to SomeoneWhoWroteAccessOnce
    SomeoneWhoWroteAccessOnce:
    bstorer:
    The correct solution isn't disabling the warning. How hard is it to add the freaking 'F'?
    Indeed, it always amazes me that people consider warnings to be added to the compiler by "annoying consultants with nothing better to do than scream at honest programmers", instead of "honest programmers who have run into bug X so often they want to warn people that behavior Y really increases the chance of bug X".
    Look, I love programmers.

    Actually, I'm infatuated with consultants. I even want to have their babies (but I'm not going to tell you what for).

    Isn't it just the slightest bit possible that the people who write compilers (with warnings, and all) aren't your typical programmers, let alone consultants?

    Or am I just being presumptuous in calling you a dipstick?

  • real_aardvark (cs) in reply to NXavier
    NXavier:
    Beeblebrox:
    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.

    Legacy, my good man. Legacy.

    What? You mean we're supposed to maintain that five-year-old crap we wrote on Windows for another five years?

    What are you, some sort of goddamn Access programmer?

  • real_aardvark (cs) in reply to dpm
    dpm:
    SomeoneWhoWroteAccessOnce:
    Indeed, it always amazes me that people consider warnings to be added to the compiler by "annoying consultants with nothing better to do than scream at honest programmers"

    I have inherited a few hundred thousand lines of C and C++ code, which results in hundreds of lines like this:

       warning: implicit declaration of function 'strlen'
    

    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.

    Sadly, and I mean sadly (because I just don't have time to go into the cultural issues here), the answer is "Outsourcing."

    Not bad in and of itself.

    However, I noticed the same problem myself, around eight years ago. The overnight build was spewing out an incredible number of warnings, some of which were quite serious ("Warning: this object may not be fully constructed").

    I wrote some sort of script -- I forget what,, but it was probably ksh -- to filter this down to what I thought were the potentially fatal errors, and passed the results on to management.

    Their response?

    "Why are you bothering us with this?"

    Why, indeed.

  • sparr (unregistered) in reply to Beeblebrox
    Beeblebrox:
    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.

    I take offense to your labeling "whatever rules Microsoft makes up this quarter" as "standards".

  • dpm (cs) in reply to jhamby
    jhamby:
    dpm:
    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.
    OMG, didn't you know they're up to V7.3 of the compilers now?

    Oh for the joy of being allowed to upgrade.

    I am maintaining code written fifteen to twenty years ago. Most of it is in FORTRAN. My previous job was cutting-edge: I was at an HP workshop when VMS for Itanium came out, to get the code working, and went through another wave to have our product V8.3-compatible as soon as it was released. But here everything is frozen in time, and dangerous innovations like source-code-control software are de facto forbidden.

    And we're hiring! Apply now!

  • Invalid User Credentials (unregistered) in reply to gabba
    gabba:
    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'.

    The best part is that the two 0.4's may look different but might actually be the same.

    I just checked and 0.4f turned out to be approximately 0.400000006, to which 0.40000001f is even closer, so it should come as no surprise that it is actually the SAME value as 0.4f.

    (This was GNU C++ on Solaris / SPARC, curiously in both the 32-bit and 64-bit incarnations of the compiled test program. Your mileage may very.)

  • GF (unregistered) in reply to documentation man
    documentation man:
    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)

    Erm, you realize that (float)1.0 involves one fewer keystroke? And that 1.0f involves /many/ fewer keystrokes?

    captcha: acsi Usage: I acsi you to learn how to code, but you do not listen.

  • GF (unregistered) in reply to Corona688
    Corona688:
    Visual Studio 6 is the only version that doesn't insert .net dependencies whether you're using them or not.
    Erm.... riiight. have you ever tried running it? This is incorrect. If you build a C++ native project, it simply doesn't happen.

    Now back to the topic at hand: we upgraded our compiler to vs8, and received [naturally] tons of warnings. We sent it offshore to fix the warnings at the same time as other necessary changes were made. What we get back was:

    #pragma warning(disable:x)

    Over and over again...

    captcha: feugiat usage: feugiat him, hold him still so I can take a whack.

  • Roger (unregistered) in reply to Ferd
    #define HMI_PI_N(x) (x - (HMI_1P0/(x + HMI_2P0)) + (HMI_1P0/(x + HMI_4P0)) + HMI_PI_N(x + HMI_4P0))
    #define HMI_PI HMI_PI_N(1)
    
  • Roger (unregistered) in reply to Roger

    oops, that should have ended:

    #define HMI_PI (HMI_4P0 * HMI_PI_N(HMI_1P0))
    

    obviously...

  • Jon (unregistered)

    By the way, float(1.0) is valid C++. Writing a macro like FLOAT(1.0) isn't necessary.

  • Dascandy (unregistered) in reply to Beeblebrox
    Beeblebrox:
    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.
    class X {
      public:
        X(X &);
        X(const X &);
    };
    

    Enjoy.

  • Anonny (unregistered) in reply to mabinogi
    mabinogi:
    Beeblebrox:
    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.
    Not if you're writing C. Microsoft have done exactly _nothing_ to their C support since VS 6 - so why go with a more resource hungry IDE and a slower compiler when it results in no actual gain to your project?
    I'd also add that newer versions of Visual Studio link in tons of libraries that you probably don't need. printf("Hello World!\n"); requires .net these days.

    Which is unfortunate since VC6 does have real problems and bad compiler bugs, which just have to be worked around given the lack of a good alternative.

  • Anonny (unregistered) in reply to Ben
    Ben:
    BS. We used 7.1 (and now 8) to produce c++ code that ran fine on vanilla Win98 boxes.
    I'd love to know how. That's a trick I've not yet been able to manage despite some effort.
  • cindy (unregistered)
    Comment held for moderation.

Leave a comment on “Fixing Compiler Warnings”

Log In or post as a guest

Replying to comment #:

« Return to Article