Changeset 1372

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PaulBlay
    Knight
    • Jan 2009
    • 657

    Changeset 1372

    This line causes a compiler error (well, three errors to be precise).

    Code:
    u32b dupcheck[z_info->e_max];
    error C2057: expected constant expression
    error C2466: cannot allocate an array of constant size 0
    error C2133: 'dupcheck' : unknown size

    [EDITx2] It compiles with Dev-C++ (but not with VC++?). Going to check some more things ...

    [EDITx3] Pretty sure it should be the following code (but I have an unrelated problem that is Angband/65 only. :-(

    Code:
    	u32b *dupcheck;
    	dupcheck = C_ZNEW(z_info->e_max, u32b);
    Last edited by PaulBlay; April 22, 2009, 11:36.
    Currently turning (Angband) Japanese.
  • Pete Mack
    Prophet
    • Apr 2007
    • 6883

    #2
    That array initialization is a C99-ism. Your fix will solve it, if you really want to. Don't forget to free dupcheck when you are done with it.

    Comment

    • Magnate
      Angband Devteam member
      • May 2007
      • 5110

      #3
      Originally posted by Pete Mack
      That array initialization is a C99-ism. Your fix will solve it, if you really want to. Don't forget to free dupcheck when you are done with it.
      This causes me a problem. I wrote that code, and it compiled cleanly on gcc with no warnings whatsoever. But I know that Angband is supposed to be C89-compliant, because ajps and others often correct my code to C89 standards. Is there a way that I can tell gcc to be strict about C89?

      @paul: thanks for the tip - I'll correct it tonight. I didn't think you had to use C_ZNEW if you were throwing the array away at the end of the function (which we are in this case).
      "Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles

      Comment

      • Magnate
        Angband Devteam member
        • May 2007
        • 5110

        #4
        Originally posted by Magnate
        This causes me a problem. I wrote that code, and it compiled cleanly on gcc with no warnings whatsoever. But I know that Angband is supposed to be C89-compliant, because ajps and others often correct my code to C89 standards. Is there a way that I can tell gcc to be strict about C89?
        Come to think of it, since I invoke gcc via make, shouldn't whatever does this go into the Angband makefiles?
        "Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles

        Comment

        • takkaria
          Veteran
          • Apr 2007
          • 1951

          #5
          Originally posted by Magnate
          Come to think of it, since I invoke gcc via make, shouldn't whatever does this go into the Angband makefiles?
          I think the problem here is that the autoconf buildsystem don't have the same flags as Makefile.std does, the latter of which I use for most development. I'll have a look into transferring the flags across.
          takkaria whispers something about options. -more-

          Comment

          • Magnate
            Angband Devteam member
            • May 2007
            • 5110

            #6
            Fixed in r1374. Thanks Paul.
            "Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles

            Comment

            • Nick
              Vanilla maintainer
              • Apr 2007
              • 9637

              #7
              Originally posted by Pete Mack
              That array initialization is a C99-ism. Your fix will solve it, if you really want to. Don't forget to free dupcheck when you are done with it.
              Ah, that explains why stuff like that didn't compile cleanly for me a while ago (probably for WinCE in eVC++). Keep it up, Pete - I'll be a programmer one day.
              One for the Dark Lord on his dark throne
              In the Land of Mordor where the Shadows lie.

              Comment

              • Pete Mack
                Prophet
                • Apr 2007
                • 6883

                #8
                Originally posted by Magnate
                This causes me a problem. I wrote that code, and it compiled cleanly on gcc with no warnings whatsoever. But I know that Angband is supposed to be C89-compliant, because ajps and others often correct my code to C89 standards. Is there a way that I can tell gcc to be strict about C89?
                From http://gcc.gnu.org/onlinedocs/gcc-3....Standards.html
                Possibilities include:

                -std=c89 or -std=iso9899:1990

                Don't apply this uniformly on the OSX build, because main-crb.c requires std=g99, as well as objective C.

                Comment

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