3.2 problem with process_command()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • APWhite
    Adept
    • Jul 2007
    • 244

    3.2 problem with process_command()

    Looks like VS2008 is getting even more picky these days.

    Code:
    void process_command(cmd_context ctx, bool no_request)
    {
    	game_command *cmd;
    
    	/* Reset so that when selecting items, we look in the default location */
    	p_ptr->command_wrk = 0;
    
    	/* If we've got a command to process, do it. */
    	if (cmd_get(ctx, &cmd, !no_request) == 0)
    	{
    		int oldrepeats = cmd->nrepeats;
    		int idx = cmd_idx(cmd->command);
    
    		if (idx == -1) return;
    
    		for (size_t i = 0; i < N_ELEMENTS(item_selector); i++)
    		{
    			struct item_selector *is = &item_selector[i];
    Is yeilding the following errors:
    Code:
    .\src\game-cmd.c(396) : error C2143: syntax error : missing ';' before 'type'
    .\src\game-cmd.c(396) : error C2143: syntax error : missing ';' before 'type'
    .\src\game-cmd.c(396) : error C2143: syntax error : missing ')' before 'type'
    .\src\game-cmd.c(396) : error C2143: syntax error : missing ';' before 'type'
    .\src\game-cmd.c(396) : error C2065: 'i' : undeclared identifier
    .\src\game-cmd.c(396) : warning C4552: '<' : operator has no effect; expected operator with side-effect
    .\src\game-cmd.c(396) : error C2065: 'i' : undeclared identifier
    .\src\game-cmd.c(396) : error C2059: syntax error : ')'
    .\src\game-cmd.c(397) : error C2143: syntax error : missing ';' before '{'
    .\src\game-cmd.c(398) : error C2065: 'i' : undeclared identifier
    .\src\game-cmd.c(401) : error C2044: illegal continue
    Looks like my config of VS2008 does like the size_t.
    St George Chiropractor
    Angband Borg Homepage
  • Omnipact
    Rookie
    • Jun 2007
    • 23

    #2
    This line is where my compile originally failed.
    GCC was helpful in saying to put the switch '-std=c99' in.

    Maybe VS is in c89 mode? You may need to find the 'my code is c99' checkbutton/switch.

    EDIT: A quick google shows that Visual Studio does not support c99 and m$ aren't very interested in it for the future either.
    One suggestion I seen is renaming the file to '.cpp' to allow initialisation inside a loop.



    Iain
    Last edited by Omnipact; December 25, 2010, 09:52.

    Comment

    • takkaria
      Veteran
      • Apr 2007
      • 1951

      #3
      I'm sorry about that, I'm not sure how I wasn't get warnings about it-- I thought I had the right ones turned on.

      Try just moving size_t out of the for statement:

      Code:
      void process_command(cmd_context ctx, bool no_request)
      {
      	game_command *cmd;
      
      	/* Reset so that when selecting items, we look in the default location */
      	p_ptr->command_wrk = 0;
      
      	/* If we've got a command to process, do it. */
      	if (cmd_get(ctx, &cmd, !no_request) == 0)
      	{
      		int oldrepeats = cmd->nrepeats;
      		int idx = cmd_idx(cmd->command);
      		size_t i;
      
      		if (idx == -1) return;
      
      		for (i = 0; i < N_ELEMENTS(item_selector); i++)
      		{
      			struct item_selector *is = &item_selector[i];
      takkaria whispers something about options. -more-

      Comment

      • Dean Anderson
        Adept
        • Nov 2009
        • 193

        #4
        Originally posted by takkaria
        Try just moving size_t out of the for statement:
        That's what I've been having to do to get it to compile under VS2010.

        Comment

        • d_m
          Angband Devteam member
          • Aug 2008
          • 1517

          #5
          This size_t declaration is fixed in staging--that fix should soon go to master.
          linux->xterm->screen->pmacs

          Comment

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