Weird Problem?

This is a discussion on Weird Problem? within the C++ Programming forums, part of the General Programming Boards category; Ok, I wormed out all my errors, now all I have are warnings. For some reason my game isint finding ...

  1. #1
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379

    Weird Problem?

    Ok, I wormed out all my errors, now all I have are warnings. For some reason my game isint finding the right tile.

    I'm getting this error:

    Code:
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    
    C:\Documents and Settings\User 1>CD C:\Borland\BCC55\BIN
    
    C:\Borland\BCC55\Bin>BCC32 C:\MazeOfPain.cpp
    Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
    C:\MazeOfPain.cpp:
    Warning W8068 C:\MOPEngine.h 162: Constant out of range in comparison in functio
    n MoveRight()
    Warning W8068 C:\MOPEngine.h 162: Constant out of range in comparison in functio
    n MoveRight()
    Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
    Now, my problem is that MoveRight() is pritty big. I isolated line 162:
    Code:
    Death(); //162
    My line before that however:
    Code:
    if(Saveme[0] == Enemy1 || Saveme[0] == Enemy2 || Saveme[0] == Enemy3 || Saveme[0] == Enemy4)
      Death(); //162
    I have them declared as they should be:

    Code:
    #define Enemy1 '@'
    #define Enemy2 '&' 
    #define Enemy3 '$'
    #define Enemy4 '%'
    Death function:

    Code:
    void Death() { //Not finished.
     clrscr();
     exit(0);
    }
    I dont get why its saying its out of range?? I have like 50 other constants that work just fine.
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  2. #2
    Dae
    Dae is offline
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    I've read that bcc32 has this problem, where gcc and others do not. I'm not recommending to do it yet, incase I just don't see where the problem is (most likely), but you could try disabling that warning. I think this page has that information: -w-rng.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  3. #3
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    Its a problem though, its not the warning, its actualy not even reading that the character's their. I'm doublechecking my co-ordinants to see if I messed up on something obvious.
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  4. #4
    Dae
    Dae is offline
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Try making them constants and not macros? (I don't know if those macros are right either... I skipped C). Just for the hell of it I'd try wrapping your if statement more logically.

    Code:
    const char Enemy1 = '@';
    const char Enemy2 = '&';
    const char Enemy3 = '$';
    const char Enemy4 = '%';
    
    if((Saveme[0] == Enemy1) || (Saveme[0] == Enemy2) || (Saveme[0] == Enemy3) || (Saveme[0] == Enemy4))
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  5. #5
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    
    #define Enemy1 '@'
    #define Enemy2 '&' 
    #define Enemy3 '$'
    #define Enemy4 '%'
    
    void Death(void)
    { //Not finished.
       clrscr();
       exit(0);
    }
    
    void foo(const char *Saveme)
    {
       if ( Saveme[0] == Enemy1 || Saveme[0] == Enemy2 || 
            Saveme[0] == Enemy3 || Saveme[0] == Enemy4 )
       {
          Death();
       }
    }
    
    int main (void)
    {
       char Saveme[] = "@";
       foo(Saveme);
       return 0;
    }
    Code:
    	c:\progra~1\borland\bcc55\bin\bcc32 -P- -c @MAKE0000.@@@
    Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
    test.c:
    	c:\progra~1\borland\bcc55\bin\Ilink32 @MAKE0002.@@@
    Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
    	c:\progra~1\borland\bcc55\bin\bcc32 -P- -S @MAKE0001.@@@
    Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
    test.c:
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  6. #6
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    Yeah I dont know why this code is giving me an error... Weirder still is its only complaining about two of them, but they're four comparisons...

    if((Saveme[0] == Enemy1) || (Saveme[0] == Enemy2) || (Saveme[0] == Enemy3) || (Saveme[0] == Enemy4))

    Saveme[0] is not a constant char. (And it cant be either)
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  7. #7
    Dae
    Dae is offline
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Quote Originally Posted by Blackroot
    Saveme[0] is not a constant char. (And it cant be either)
    So? In your code you are only comparing them.

    I blame it on bcc obviously, who knows what whacked up rules it has. Maybe you cant use macros like that, or initialize an array like that. I never liked Borland, but it was the first program I used so I of course didn't understand it.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  8. #8
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    I fixed it by making a seperate function to return its value -,-. Ah well, it works now. Thank you for your help .
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  9. #9
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    Perhaps you have other enemies in a nearer scope to the comparison, which have a larger range.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Weird Problem With Pointer
    By DarkDot in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2007, 07:50 PM
  2. Weird problem on '02 3.4L V6 auto
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 01-11-2006, 11:05 PM
  3. Really Weird itoa Problem
    By Grantyt3 in forum C++ Programming
    Replies: 8
    Last Post: 12-19-2005, 11:44 PM
  4. Replies: 6
    Last Post: 05-12-2005, 03:39 AM
  5. Weird class problem!
    By aker_y3k in forum C++ Programming
    Replies: 2
    Last Post: 09-25-2002, 06:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21