bool_hack?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chris
    PosChengband Maintainer
    • Jan 2008
    • 702

    bool_hack?

    I'm puzzled ... I was curious about this:
    Code:
    #define bool bool_hack
    If I grep the entire source directory for bool_hack, this is the only occurrence I find. It this built in for C or something? It seems to be
    Code:
    typedef char bool_hack;
    but I can't find that code any place.

    Thanks,
    --Chris
  • chris
    PosChengband Maintainer
    • Jan 2008
    • 702

    #2
    Yeah, looks like this has been discussed already ...

    Comment

    • chris
      PosChengband Maintainer
      • Jan 2008
      • 702

      #3
      I am so puzzled by this. If I change code to:
      Code:
      #undef bool
      #define bool bool_hackz
      It still works. And I *know* that bool_hackz is never defined It must be some compiler voodoo in the case that somebody #defines bool to something ...

      Of course, this gives the expected type undefined:
      Code:
      #undef chris
      #define chris chris_hack
      ...
      chris x = TRUE;

      Weird.

      Comment

      • takkaria
        Veteran
        • Apr 2007
        • 1951

        #4
        Originally posted by chris
        I am so puzzled by this. If I change code to:
        Code:
        #undef bool
        #define bool bool_hackz
        It still works. And I *know* that bool_hackz is never defined It must be some compiler voodoo in the case that somebody #defines bool to something ...

        Of course, this gives the expected type undefined:
        Code:
        #undef chris
        #define chris chris_hack
        ...
        chris x = TRUE;

        Weird.
        Think it through. #define bool bool_hack comes before the typedef char bool; -- so the 'bool' type is never defined, bool_hack is.
        takkaria whispers something about options. -more-

        Comment

        • chris
          PosChengband Maintainer
          • Jan 2008
          • 702

          #5
          Originally posted by takkaria
          Think it through. #define bool bool_hack comes before the typedef char bool; -- so the 'bool' type is never defined, bool_hack is.
          Oh, OK. My greps on "bool_hack" missed the
          Code:
          typedef char bool;
          That makes sense now ...

          Comment

          • chris
            PosChengband Maintainer
            • Jan 2008
            • 702

            #6
            Yeah, and I see the typedef comes just 13 lines later ... tunnel vision.

            Thanks for clearing that one up

            --Chris

            Comment

            • Nick
              Vanilla maintainer
              • Apr 2007
              • 9634

              #7
              I hope you retained bool_hackz
              One for the Dark Lord on his dark throne
              In the Land of Mordor where the Shadows lie.

              Comment

              • chris
                PosChengband Maintainer
                • Jan 2008
                • 702

                #8
                Originally posted by Nick
                I hope you retained bool_hackz
                Hah! No ... I'm tempted now, though

                Comment

                • takkaria
                  Veteran
                  • Apr 2007
                  • 1951

                  #9
                  Originally posted by chris
                  Hah! No ... I'm tempted now, though
                  All this mess will hopefully go away pretty soon when we move to C99 types. It's a shame, I like Angband header files being fun little logic puzzles...
                  takkaria whispers something about options. -more-

                  Comment

                  • chris
                    PosChengband Maintainer
                    • Jan 2008
                    • 702

                    #10
                    OK, I worked really hard on this, and I think I found the problem. There is some funny looking code in my copy of developer.c, but I'm not quite sure how to fix it. Any ideas?

                    Code:
                    /* developer.c */
                    ...
                    /*
                     * Figure out what went wrong
                     */
                    void assign_blame(void)
                    {
                      if (randint1(1000 * 1000) <= 0)
                        msg_print("Ooops!  My bad!");
                      else
                      {
                        switch(randint1(8))
                        {
                        case 1:
                          msg_print("It's a compiler bug!");
                          break;
                        case 2:
                          msg_print("It's the last developers fault!");
                          break;
                        case 3:
                          msg_print("It's compiler voodoo!");
                          break;
                        case 4:
                          msg_print("Damn Micro$oft!!!!");
                          break;
                        case 5:
                          msg_print("User error.");
                          break;
                        case 6:
                          msg_print("Works as designed.");
                          break;
                        case 7:
                          msg_print("I can't reproduce, so you must be imagining things.");
                          break;
                        case 8:
                          msg_print("Works as designed.");
                          break;
                        case 9:
                          /* At my last performance review, it was pointed out that I don't own
                           * up to my mistakes.  This should shut my boss up for a while ...
                           */
                          msg_print("I'm sorry, that's clearly my fault.");
                          break;      
                        }
                      }
                    }
                    ...
                    /*
                     * Handle developer state every 10 turns
                     */
                    void process_developer_aux(void)
                    {
                      ...
                      if (developer_is_confused())
                        assign_blame();
                        
                      if (bug_count > old_bug_count)
                      {
                        assign_blame();
                        old_bug_count = bug_count;
                      }
                      ...
                    }
                    Last edited by chris; November 14, 2010, 22:53.

                    Comment

                    Working...
                    😀
                    😂
                    🥰
                    😘
                    🤢
                    😎
                    😞
                    😡
                    👍
                    👎