Compiling using Makefile.nmake

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

    Compiling using Makefile.nmake

    I'm trying to compile Angband 3.1.0 using Visual Studio 2008 and Makefile.nmake

    It seems that there are a lot of .c files in subdirectories with lines like ...

    #include "angband.h"

    that all need to be changed to

    #include "../angband.h"

    in order for it to compile. A quick look at the SVN version shows that the same lines are present (without any ../ ). Does this mean the Makefile.nmake needs to be changed or is there some command line setting or something I'm missing?
    Currently turning (Angband) Japanese.
  • PaulBlay
    Knight
    • Jan 2009
    • 657

    #2
    Trying again with the SVN source.

    death.c
    The line
    Code:
     	const region area = { 51, 2, 0, menu->count };
    is not accepted where it (now) is by the compiler. I get the error
    missing ; before const

    If I change the last parameter to 7 and put it back where it was then it will compile.
    Code:
    void death_screen(void)
    {
    	menu_type *menu;
    	const char cmd_keys[] = { ARROW_LEFT, ARROW_RIGHT, '\0' };
    	const region area = { 51, 2, 0, 7 };
    Currently turning (Angband) Japanese.

    Comment

    • PowerDiver
      Prophet
      • Mar 2008
      • 2820

      #3
      Originally posted by PaulBlay
      #include "angband.h"

      that all need to be changed to

      #include "../angband.h"
      The configure script ought to set up the makefile to call the compiler with some flags -Isomedirectory, and angband.h needs to be in one of the dirs indicated by one of those.

      Comment

      • PowerDiver
        Prophet
        • Mar 2008
        • 2820

        #4
        Originally posted by PaulBlay
        Trying again with the SVN source.

        death.c
        The line
        Code:
         	const region area = { 51, 2, 0, menu->count };
        is not accepted where it (now) is by the compiler. I get the error
        missing ; before const

        If I change the last parameter to 7 and put it back where it was then it will compile.
        Code:
        void death_screen(void)
        {
        	menu_type *menu;
        	const char cmd_keys[] = { ARROW_LEFT, ARROW_RIGHT, '\0' };
        	const region area = { 51, 2, 0, 7 };
        The compiler wants to set a constant structure for the area, at compile time. If menu->count is not a const, it cannot do that.

        The error message seems a little strange unless macros are involved. You should also check that you did not somehow remove the ; on the cmd_keys line.

        Comment

        • PaulBlay
          Knight
          • Jan 2009
          • 657

          #5
          Originally posted by PowerDiver
          The configure script ought to set up the makefile to call the compiler with some flags -Isomedirectory, and angband.h needs to be in one of the dirs indicated by one of those.


          OK, the Makefile.nmake file in the SVN needs to have line 22 changed to
          Code:
          CFLAGS = $(CFLAGS) /O2 /Os /Gs /I.
          and line 24 needs to be changed to
          Code:
          CFLAGS = $(CFLAGS) /Od /Zi /I.
          Currently turning (Angband) Japanese.

          Comment

          • Pete Mack
            Prophet
            • Apr 2007
            • 6883

            #6
            Having the menu region declared way down in the procedure body requires C99, not C90 (or iso9899)

            I don't recall what the right option to cl.exe is to enable this.

            (It has nothing to do with constness, except insofar as you can't have good constness in c90 proper without running into used-before-set problems.)

            Comment

            • PaulBlay
              Knight
              • Jan 2009
              • 657

              #7
              Originally posted by Pete Mack
              Having the menu region declared way down in the procedure body requires C99, not C90 (or iso9899)

              I don't recall what the right option to cl.exe is to enable this.
              I get the impression that Visual Studios 2008 only partially supports C99 so there might not be an option for that. I suppose the point here is that it probably isn't good code for something that needs to work on a wide variety of platforms compiled by many different compilers.

              [EDIT]/Ze enables extensions - but that is supposed to be on by default.
              [EDIT*2]Yes, I checked and /Ze doesn't change anything.
              Last edited by PaulBlay; February 19, 2009, 18:27.
              Currently turning (Angband) Japanese.

              Comment

              • PaulBlay
                Knight
                • Jan 2009
                • 657

                #8
                Same problem with init2.c line 735 in init_r_info

                The 'int i' should be at the start of the function.

                With that corrected I get no more compile errors with Visual Studios 2008 (nmake). I get a ton of warning messages though

                [EDIT]OK, looking at compiler warnings ...
                attack.c(592) : warning C4244: '+=' : conversion from 's32b' to 'byte', possible loss of data
                Code:
                m_ptr->confused += 10 + randint0(p_ptr->lev) / 5;
                I guess 'confused' could suffer from overflow if there are 10 successive successful hits from a level 100 character. Not very likely to happen. ;-)

                The following code stops the compiler warning for Visual Studio 2008 (don't know if it will break it for any other compiler though)

                Code:
                /* Suppresses compiler warning. Conversion is safe given player max level */
                m_ptr->confused += 10 + (byte)randint0(p_ptr->lev) / 5;
                birth.c(1667) : warning C4090: 'function' : different 'const' qualifiers
                from
                Code:
                mem_free(race_choices);
                According to a page Google found there isn't any real fix for that but the warning can be avoided by
                Code:
                mem_free((void *)race_choices);
                Again I don't know if that is wise.

                There are a lot of 'security' warnings. Unfortunately the suggestions given by Visual Studio seem to be Microsoft specific. I suppose equivalent solutions could be found / written if really necessary.

                death.c(97) : warning C4996: 'ctime': This function or variable may be unsafe. Consider using ctime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\time.inl(88) : see declaration of 'ctime'

                Back to more serious looking warnings

                util.c(2348) : warning C4550: expression evaluates to a function which is missing an argument list
                Referring to
                Code:
                keypress_h = askfor_aux_keypress;
                The function askfor_aux_keypress is given with
                Code:
                bool askfor_aux_keypress(char *buf, size_t buflen, size_t *curs, size_t *len, char keypress, bool firsttime)
                Last edited by PaulBlay; February 19, 2009, 20:46.
                Currently turning (Angband) Japanese.

                Comment

                • zaimoni
                  Knight
                  • Apr 2007
                  • 590

                  #9
                  Originally posted by PaulBlay
                  Back to more serious looking warnings

                  util.c(2348) : warning C4550: expression evaluates to a function which is missing an argument list
                  Referring to
                  Code:
                  keypress_h = askfor_aux_keypress;
                  The function askfor_aux_keypress is given with
                  Code:
                  bool askfor_aux_keypress(char *buf, size_t buflen, size_t *curs, size_t *len, char keypress, bool firsttime)
                  MS is bungling the ISO-required promotion of a naked function name to a function pointer.

                  What MS wants

                  Code:
                  keypress_h = &askfor_aux_keypress;
                  is accepted by MingW32 4.2.1 (the & is a no-op).
                  Zaiband: end the "I shouldn't have survived that" experience. V3.0.6 fork on Hg.
                  Zaiband 3.0.10 ETA Mar. 7 2011 (Yes, schedule slipped. Latest testing indicates not enough assert() calls to allow release.)
                  Z.C++: pre-alpha C/C++ compiler system (usable preprocessor). Also on Hg. Z.C++ 0.0.10 ETA December 31 2011

                  Comment

                  • PaulBlay
                    Knight
                    • Jan 2009
                    • 657

                    #10
                    Originally posted by zaimoni
                    MS is bungling the ISO-required promotion of a naked function name to a function pointer.

                    What MS wants

                    Code:
                    keypress_h = &askfor_aux_keypress;
                    is accepted by MingW32 4.2.1 (the & is a no-op).
                    Thanks. That makes more sense to me anyway.
                    Currently turning (Angband) Japanese.

                    Comment

                    • Pete Mack
                      Prophet
                      • Apr 2007
                      • 6883

                      #11
                      Originally posted by PaulBlay
                      Thanks. That makes more sense to me anyway.
                      It's damn strange looking to me, anyway. Removing the () from a function is supposed to be all it takes to turn it into an FP. Rather than "fix" it, I'd disable that (broken) warning in the appropriate windows-specific include file:

                      #pragma warning(disable:4550)

                      (MINGW/gcc will simply ignore this.)

                      Comment

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