Thread: VS 2003 compile issues?

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    9

    VS 2003 compile issues?

    The following compiles in msvc++ 6 but on in vs203, any ideas?

    Code:
    // some loser chess game
    
    #include <iostream>
    #include <math.h>
    
    using namespace std;
    
    int fun(int x, int y)// najes 1d array 2d array
    {
    	return (8*y+x);
    }
    
    
    
    void naming(int p)// bind a number to each piece(positive white, negitive black)
    {
    	
    	if (p == 1)
    	cout << "  P";
    	if (p == 2)
    	cout << "  R";
    	if (p == 3)
    	cout << "  K";
    	if (p == 4)
    	cout << "  B";
    	if (p == 5)
    	cout << "  V";
    	if (p == 6)
    	cout << "  Q";
    	if (p == 0)
    	cout << "  -";
    	if (p == -1)
    	cout << "  p";
    	if (p == -2)
    	cout << "  r";
    	if (p == -3)
    	cout << "  k";
    	if (p == -4)
    	cout << "  b";
    	if (p == -5)
    	cout << "  v";
    	if (p == -6)
    	cout << "  q";
    }
    
    void drawchessboard(int chess[]) // draw the chess board
    {
    	cout << endl << endl << endl << "   1  2  3  4  5  6  7  8"  << endl;
    	int b;
    	for(int x = 0; x < 8 ;x++)
    	{
    		cout << "		" << endl << endl << x+1;
    		for(int y = 0; y < 8; y++)
    		{
    			b = fun(y,x);
    			naming(chess[b]);
    		}
    	}
    }
    
     
    
    bool game(int chess[]) // set up the win/lose function
    {
    	int b;
    	int w;
    	for( p = 0; p < 64; p++)
    	{
    		if (chess[p] == 5)
    		w = 1;
    		if (chess[p] == -5)
    		b = 1;
    		if (b == 1 && w ==1)
    			return true;
    	}
    	
    	return false;
    	if (b == 1 && w ==0)
    	cout << "black wins";
    	else
    		cout << "White Wins";
    
    }
    
    
    void execute(int sx, int dx, int sy, int dy, int chess[]) // give moove function
    {
    	chess[fun(dx,dy)] = chess [fun(sx,sy)];
    	chess[fun(sx, sy)] = 0;
    }
    
    bool legalmove(int sx, int dx, int sy, int dy, int st, int dt) // check to se if it is a legal moove
    
    { 
    	if (abs(dx-sx) == 0 && abs(dy-sy) == 0 )  // cant moove to current position
    		return false;
    	else if (abs(st) == 2 && (abs(sy-dy)==0 || abs(sx-dx)==0)) // if rook and moving forward,back,left,or right then it can moove
    		return true;
    	else if (abs(st) == 4 && abs(dx-sx) == abs(sy-dy))// checks to maek sure bishop is mooving diagonally
    		return true;
    	else if (abs(st) == 5 && abs(dx-sx) <= 1 && abs(dy-sy) <= 1)
    		return true;
    	else if (abs(st) == 6 && ((abs(sy-dy)==0) || abs(sx-dx)==0) || (abs(dx-sx) == abs(sy-dy)))
    		return true;
    	else if (abs(st) == 3 && (abs(sy-dy) == 1 && abs(sx-dx) == 2) || (abs(sy-dy) ==2 && abs(sx-dx) == 1))
    		return true;
    	else if ((st) == 1 && (dy-sy) == 1 && dt == 0 && (dx-sx) == 0)
    		return true;
    	else if ((st) == 1 && (dy-sy) == 2 && dt == 0 && (dx-sx) == 0 && sy == 1)
    		return true;
    	else if ((st) == 1 && abs(dx-sx) == 1 && (dy-sy) == 1 && dt < 0)
    		return true;
    	else if ((st) == -1 && (dy-sy) == -1 && dt == 0 && (dx-sx) == 0)
    		return true;
    	else if ((st) == -1 && (dy-sy) == -2 && dt == 0 && (dx-sx) == 0 && sy == 6)
    		return true;
    	else if ((st) == -1 && abs(dx-sx) == 1 && (dy-sy) == -1 && dt > 0)
    		return true;
    	// kyles mom
    		return false;
    }
    
    bool inbounds(int sx, int dx, int sy, int dy)
    {
    	if (sx > -1 && sx < 8 && dx > -1 && dx < 8 && sy > -1 && sy < 8 && dy > -1 && dy < 8)
    	return true;
    	else
    	return false;
    }
    
    bool turn(int color, int st)
    {
    	if(color == 0 && st > 0)
    	return true;
    	if(color == 1 && st < 0)
    	return true;
    	else
    	return false;
    }
    
    // MAIN _________________
    int main()
    {
    	int chess[64] = {2, 3, 4, 5, 6, 4, 3, 2, 1,1,1,1,1,1,1,1, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    						-1, -1, -1, -1, -1, -1, -1, -1, -2, -3, -4, -6, -5, -4, -3, -2};
    
    int sx, sy, dx, dy, col, st, dt;
    
    int color =  0;
    
    while  (game(chess))
    	{
    		drawchessboard(chess);
    		if (color)
    			
    			cout << endl << endl << "it is black's turn";
    			else cout << endl << endl << "it is white's turn";
    	
    		
    		
    		
    		cout << endl << endl << "please type in the x and y coordinates of the selected piece and the destination of the piece in that order." << endl;
    		cin >> sx >> sy >> dx >> dy;
            sx--;sy--;dx--;dy--;
    
    		if (inbounds(sx, dx, sy, dy))
    		{
    			st = chess[fun(sx, sy)];
    			dt = chess[fun(dx, dy)];
    			if ((st * dt <= 0) && legalmove(sx, dx, sy, dy, st, dt) && turn(color, st))
    			{
    
    				execute(sx, dx, sy, dy, chess);	
    				color =!color;
    				
    			}
    			else
    				cout << "illegal move";
    		}
    			
    	}
    	cin.get();
    	return 0;
    }
    i get the following error

    \My Documents\Visual Studio Projects\chess\chess.cpp(187): fatal error C1010: unexpected end of file while looking for precompiled header directive

  2. #2
    Software engineer
    Join Date
    Aug 2005
    Location
    Oregon
    Posts
    283
    When you created your project, did you say to include any pre-compiled headers? If so, that's the problem. Make a new project and uncheck it, then copy your code back on and compile. I hope this helps.

  3. #3
    Registered User
    Join Date
    Aug 2005
    Location
    Pasadena, CA
    Posts
    6

    Smile

    Go to project properties under the project menu. Select C++ under configuration properties and select precompiled headers. In the righ hand pane under Create/Use precompiled headers change the pulldown to inherit from project defaults. Then that error should go away. I had that problem before and it was most frustrating to get rid of it. I used the f1 key to get help and the help text helped me figured out what was going on.


  4. #4
    Banned
    Join Date
    Jun 2005
    Posts
    594
    once you get that error gone, you will notice
    that p in game() function hasnt been declared.

  5. #5
    Registered User
    Join Date
    Aug 2005
    Posts
    9
    thank you all so much

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 05-07-2009, 11:31 AM
  2. MSVS 2003, 2005 debugger issues
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 01-19-2009, 07:41 PM
  3. Annoying compilers
    By anon in forum A Brief History of Cprogramming.com
    Replies: 42
    Last Post: 12-14-2008, 04:30 AM
  4. anti-standard code can compile -- about template class
    By George2 in forum C++ Programming
    Replies: 10
    Last Post: 03-07-2008, 06:14 AM
  5. compile once, compile twice ...error
    By Benzakhar in forum Windows Programming
    Replies: 6
    Last Post: 12-28-2003, 06:00 AM