[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Errors from includes & casts
From: |
DARREN MATTHEW SCHREIBER |
Subject: |
Errors from includes & casts |
Date: |
Fri, 10 Sep 1999 16:32:58 -0700 (PDT) |
I recently changed one my methods in SchellingWorld.h to the following:
-findEmptyLocation: o {
int x,y;
int i;
id anEmptySpace;
i=[modelSwarm getRandomIntMin: 0 Max: [emptySpacesList getCount]];
printf(" The value of i is %d \n", i);
// Get an empty location from the list
anEmptySpace=[emptySpacesList atOffset: i];
x=[anEmptySpace getX];
y=[anEmptySpace getY];
[emptySpacesList remove: anEmptySpace];
[anEmptySpace drop];
return [self move: o toX: x Y: y];
}
First, a simple question. Do I need to both remove the emptySpace from
the emptySpacesList and drop it? (this object will never exist again)
When I compile SchellingWorld, I am getting the following errors:
SchellingWorld.m: In function `_i_SchellingWorld__findEmptyLocation_':
SchellingWorld.m:64: warning: cannot find method.
SchellingWorld.m:64: warning: return type for `getRandomIntMin:Max:'
defaults to id
SchellingWorld.m:64: warning: assignment makes integer from pointer
without a cast
It will compile, but when it runs I get the following:
*** event raised for error: OffsetOutOfRange
*** function: indexAtOffset(), file:
/src/Swarm/swarm/src/collections/Collection.m, line: 73
*** execution terminating due to error
I have been using a method to setModelSwarm. I am guessing that this is
why it doesn't find the method getRandomIntMin:Max. I don't mind the
compile errors, but I have tried recasting that line by putting (int) in
various places and yet still get the errors.
So, my second question: How do I fix this error and get the casting to go
alright?
My third question: Why does the offset go out of range? I am picking a
number between 0 and the getCount for the list.
So I tried to fix this by using #import "ModelSwarm.h"
I got the following error:
In file included from Person.h:16,
from ModelSwarm.h:6,
from SchellingWorld.h:11,
from SchellingWorld.m:8:
Neighborhood.h:12: parse error before `SchellingWorld'
In file included from ModelSwarm.h:6,
from SchellingWorld.h:11,
from SchellingWorld.m:8:
Person.h:26: parse error before `SchellingWorld'
make: *** [SchellingWorld.o] Error 1
make: Target `all' not remade because of errors.
At Neighborhood.h: 12 is
SchellingWorld * myWorld;
Similarly at Person.h is
SchellingWorld * myWorld;
So my fourth question is: why is this happening?
Darren
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.
Re: NT and Window Display, Marcus G. Daniels, 1999/09/13
Re: Memory problem, Marcus G. Daniels, 1999/09/11