Thread View: comp.windows.ms.programmer
1 messages
1 total messages
Started by Jim Hu
Tue, 15 Aug 1995 15:33
Challenging Problem with Borland C ?
Author: Jim Hu
Date: Tue, 15 Aug 1995 15:33
Date: Tue, 15 Aug 1995 15:33
69 lines
3215 bytes
3215 bytes
Hi, there,
I am developing GUI seismic modelling package using XVT Portability
Toolkit. A design program comes with toolkit can design interface and
generate makefile for me. The program I wrote is compiled fine with
SUN cc and gcc. I do not have any problem at all when I run it on SPARC.
However, when I run the program on MS-Window 3.1 (compiled with Borland C
4.0), I had a general protection problem. Then I tried to track where the
problem was and I found two places I really do not undersand (Sorry for not
including the entire program since it onsists of more than twenty files an
the size is over 1 Mb):
A:
max_bed_point *= 5;
nblk = (no_bed+10)*(max_bed_point+2);
I added two printf statements as
printf("NO_BED = %d and MAX_BED_POINT = %d\n",no_bed,max_bed_point);
printf("NBLK = %d\n",nblk);
I got NO_BED = 32 and MAX_BED_POINT = 230 (they were correct) but I got
NBLK = 0 which should be 9744. Sun CC and GCC gave me 9744 here.
B: The code here is part of my input module, *no_unit here is actually
no_bed shown above
printf("READ_MODEL A\n");
for(i=0; i<(*no_unit);i++)
{no_point_unit[i] = 0; no_point_work[i]=0; printf("NO_UNIT=%d and I =
%d\n",*no_unit,i);}
printf("READ_MODEL B\n");
Guess what happened, the loop went on and on until a general protection
problem was caused, in this case i reached 447. However, *no_unit printed
out was 32. Note, only 32*4 bytes allocated for no_point_work and (32+11)*4
bytes allocated for no_point_unit.
Beside I did something very silly, I took out the two assignation statements
and then the loop went on and on with no stopping. I had to reboot the machine.
After a while, I thought there might be a virus in my PC, I used f-prot
to scan the HD, YES, I found one called antiexe. I was so glad to find it.
I used a clean boot disk to reboot the system, the virus had gone. I delete
all object files and recompiled the program again. I still had the same
problem.
Then I write a small program with the same statements and assign them
the same values as above, compiled and run it, OK, no problem.
Now I really do not understand what the problem was and come here
for your help
Could any one kindly advise me what mistakes I could make to cause this
kind of problem ? Sound like a memory overlap to me, but why the program run OK
on SPARC compiled with either SUN cc or gcc. Is the program too large for
BORLAND C to handle ?, Is it because the PC had too less memory (only 4 MB) ?.
Does BORLAND C 4.0 have any bugs ?, Or possibly some virus which f-prot
could not track ? PLEASE PLEASE advise and cc jim@gl.rhbnc.ac.uk a copy
if reply to the newgroups.
Thank in advance
Jim Hu
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads