I'm working on a program and during the evolution I ran into something I don't understand.
My program is a genealogy utility to determine relationships between people.
It started out with a single source file.
In it I had this :
DECLARE IMPORT,ZeroMemory ALIAS RtlZeroMemory( POINTER pvoid,INT length),INT
int duplicate[100000]
ZeroMemory(duplicate, 100000 * 4)
I use the array to keep track of people I've already processed. They all have ID numbers and I just set their place in the array to 1 when I process them.
But I have to be sure I'm starting with a clean slate; thus the ZeroMemory.
While it was a single source file it worked great.
I decided to split the source file up after it got really big.
I split it into 2 files and made a project out of it.
But I had all the duplicate stuff remarked out while I was doing the conversion.
The new project ran great.
That meant I needed to make the array global.
So I added the following to the $main file:
global duplicate
int duplicate[100000]
ZeroMemory(duplicate, 100000 * 4)and
extern duplicate:intin the 2nd file
Compiled and linked without errors.
When I run the program it immediately crashed with the "tell Uncle Bill" message.
Through trial and error I discovered that the line withZeroMemory(duplicate, 100000 * 4) was causing the crash.
I replaced that line with: for x=1 to 99999
duplicate[x]=0
next x
and it ran great.
Anyone got any ideas why it worked as a single file but wouldn't in a project?
Right now I've solved it using the old addage,"If it hurts when you do that then don't do that."
Larry
Shouldn't that be:
extern duplicate[10000] as int
?
Quote from: Paul Turley on May 23, 2008, 06:49:56 PM
Shouldn't that be:
extern duplicate[10000] as int
?
With or without the [100000] in the external declaration it still only crashes when I compile it with the ZeroMemory function.
And it is 100000 as opposed to 10000 because I have over 58,000 names in my family history data.
Larry
I set up a simple project with the $Main unit having the following:
$Main
extern duplicate[100000]:Int
Def I:INT
Def a$:STRING
For I = 0 to 9
print duplicate[i]
next I
INPUT "Press Enter", a$
Then in another unit the following:
DECLARE IMPORT,ZeroMemory ALIAS RtlZeroMemory( POINTER pvoid,INT length),INT
global duplicate
int duplicate[100000]
ZeroMemory(duplicate, 100000)
This worked ok on my machine. I know it doensn't help much with your problem, but indicates that using the ZeroMemory call works within a Project.
Ray
From what I was doing you have swapped where the $main was.
I'll play with it some more.
Thanks
Larry