Thread: Using TypeDefs

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    36

    Using TypeDefs

    I'm using a boolean typedef and recieivng these errors, I think it's due to the fact the way I'm passing.
    Im a little unsure since this is the first time Ive tried to use typedefs

    ERRORS:
    a3q1.c: In function `checkPawn':
    a3q1.c:45: warning: passing arg 1 of `kingInCheck' from incompatible pointer typ
    e
    a3q1.c:48: warning: passing arg 1 of `kingInCheck' from incompatible pointer typ
    e
    Undefined first referenced

    Code:
    #include<stdio.h>
    #include<stdlib.h>
    #include<ctype.h>
    
    //#define TRUE 1
    //#define FALSE 0
    #define BOARDSIZE 8
    
    typedef enum
    {
    	FALSE,TRUE
    }boolean;
    
    boolean kingInCheck(char movesBoard[],int xVal,int yVal,boolean white,int xKing,int yKing);
    
    void checkPawn(char realBoard[BOARDSIZE][BOARDSIZE],char movesBoard[BOARDSIZE][BOARDSIZE],int x, int y,int xKingW,int yKingW,int xKingB,int yKingB)
    {
    	boolean whiteInCheck=FALSE;
    	boolean blackInCheck=FALSE;
    
    	//moves
    	//if P and on line 2
    		//then can move [i][j+1] or [i][j+2]
    		//or if others in these spots[i-1][p+1]
    		//or if others in these spots[i+1][p+1]
    
    	if(realBoard[x+1][y]==' ')//empty, can move there
    	{
    		//moves the pawn to that position to test for check
    		movesBoard[x+1][y]=realBoard[x][y];
    		movesBoard[x][y]=' ';
    		whiteInCheck = kingInCheck(movesBoard,x,y,TRUE,xKingW,yKingW);
    		//if white not in check, then see if black is in check
    		if(whiteInCheck==FALSE)
    			blackInCheck = kingInCheck(movesBoard,x,y,FALSE,xKingB,yKingB);
    		if(blackInCheck==TRUE)
    		{
    			//print it results in a check
    			printf("%c%i",y+83,x);
    			printf("%2c %2c%i",'-',y+83,x+1);	//not a capture
    		}
    	}
    
    
    	//if(x==2)	//on home row can move y+2
    
    
    
    
    }
    I included the kingInCheck header to show what it's meant to be accepting as args.

    (BTW: just a basic text program to see if a move will result in a check)
    want to pass true/false because same method could check for black and white king, because ur king cant be in check for the move to be valid.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    There's a conflict between the array dimensions for the boards.

    On this prototype:
    Code:
    boolean kingInCheck(char movesBoard[],int xVal,int yVal,boolean white,int xKing,int yKing);
    The board is one dimensional, but here:
    Code:
    void checkPawn(char realBoard[BOARDSIZE][BOARDSIZE],char movesBoard[BOARDSIZE][BOARDSIZE]
    its 2d.

    So, my guess is you need to make the kingInCheck look like this;

    Code:
    boolean kingInCheck(char movesBoard[][BOARDSIZE],int xVal,int yVal,boolean white,int xKing,int yKing);
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    36
    I only seem to have the stupid errors. :P
    Thx

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Windows Typedef's
    By valaris in forum Windows Programming
    Replies: 2
    Last Post: 04-25-2009, 09:32 AM
  2. typedefs in C language
    By onebrother in forum C Programming
    Replies: 2
    Last Post: 03-28-2007, 10:58 PM
  3. Standard typedefs ...
    By twomers in forum C++ Programming
    Replies: 6
    Last Post: 02-16-2006, 10:07 AM
  4. A question about typedefs
    By cbc in forum C Programming
    Replies: 3
    Last Post: 12-23-2003, 01:44 PM
  5. how to use typedefs with structs?
    By Yourhighness in forum C Programming
    Replies: 9
    Last Post: 06-03-2003, 04:43 AM