Issue with compile on Windows 7 64-bit using Visual C++ Express command line

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • -K-
    Rookie
    • Jan 2011
    • 1

    Issue with compile on Windows 7 64-bit using Visual C++ Express command line

    Hi All,

    I've decided to try learning to program this new year, I was taught some of the basics in school, but I must disclaim that I am still very much a newbie. There is an error I had when compiling Angband, and I was wondering if someone would be willing to help explain it to me.

    Steps I took:
    1. Downloaded and extracted the angband-3.2.0.tar.gz from rehial.org to my desktop.
    2. Opened up Microsoft Visual C++ 2010 Express
    3. Clicked on "Tools"->"Visual Studio Command Prompt"
    4. Changed directory to angband-3.2.0\src\
    5. Ran "nmake /f Makefile.nmake"

    The error:

    game-cmd.c
    game-cmd.c(396) : error C2143: syntax error : missing ';' before 'type'
    game-cmd.c(396) : error C2143: syntax error : missing ';' before 'type'
    game-cmd.c(396) : error C2143: syntax error : missing ')' before 'type'
    game-cmd.c(396) : error C2143: syntax error : missing ';' before 'type'
    game-cmd.c(396) : error C2065: 'i' : undeclared identifier
    game-cmd.c(396) : warning C4552: '<' : operator has no effect; expected operator
    with side-effect
    game-cmd.c(396) : error C2065: 'i' : undeclared identifier
    game-cmd.c(396) : error C2059: syntax error : ')'
    game-cmd.c(397) : error C2143: syntax error : missing ';' before '{'
    game-cmd.c(398) : error C2065: 'i' : undeclared identifier
    game-cmd.c(401) : error C2044: illegal continue
    NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0
    \VC\BIN\cl.EXE"' : return code '0x2'
    Stop.

    I took a look at line 396 in game-cmd.c and here is the code:

    for (size_t i = 0; i < N_ELEMENTS(item_selector); i++)

    I've found that I can get around the error if I comment out like so:

    for (/*size_t */i = 0; i < N_ELEMENTS(item_selector); i++)

    I also declare "i" as an integer at the beginning of the code.

    Again, because I'm a newbie I really don't understand the code well enough to know if the fix I made is a good one, or just buggering things up further. Any help would be much appreciated.
  • zaimoni
    Knight
    • Apr 2007
    • 590

    #2
    Originally posted by -K-
    I took a look at line 396 in game-cmd.c and here is the code:

    for (size_t i = 0; i < N_ELEMENTS(item_selector); i++)

    I've found that I can get around the error if I comment out like so:

    for (/*size_t */i = 0; i < N_ELEMENTS(item_selector); i++)
    Right.

    MSVC implements C90 with a few extensions like long long, not C99. You can't declare a variable in a for loop in C90.

    Originally posted by -K-
    I also declare "i" as an integer at the beginning of the code.
    I'd declare i as size_t, although the signed/unsigned comparison warning from declaring i as int is harmless in this case.
    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

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