home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!caen!sdd.hp.com!usc!news
- From: aabdalla@pollux.usc.edu (Ahmed Abd-Allah)
- Newsgroups: comp.lang.c
- Subject: 'extern' storage type...
- Date: 29 Jul 1992 12:29:29 -0700
- Organization: University of Southern California, Los Angeles, CA
- Lines: 55
- Sender: aabdalla@pollux.usc.edu (Ahmed Abd-Allah)
- Message-ID: <l7dscpINN1jc@pollux.usc.edu>
- NNTP-Posting-Host: pollux.usc.edu
-
- I'll explain this as briefly as possible, your help is gratefully
- appreciated in advance.
-
- Recently a customer who just bought one of our products started to
- complain that the software that came with it was locking up his
- computer (IBM compatible). We use Borland's Turbo C compilers.
- Well, I went over the code, and it all seemed ok and bug free when
- I found the following POSSIBLE error. In one of the source files
- I have an array of structure-types defined, like so:
-
- struct coordinates r[25];
-
- However, in another source file, I found the following typo I made and
- didn't catch the first time around:
-
- extern struct coordinates r[5];
-
- Notice that the array is defined as having 25 spaces, but in the second
- source file I missed putting in the '2'.
-
- Now, ny question is, does this typo mess things up, or since there are
- 25 spaces allocated anyway, everythings fine? No I cant just try it and
- send it because the customer has apparently asked about this twice now,
- so I need to know BEFORE I send it to him (and he has some specialized
- hardware at his site).
-
- The last thing is that I tried generating the assembly files for the
- second source file if I tried r[], r[5], and r[25]. Here's what I found:
-
- If I put r[25] --> The code is the same as the other two ways BUT there
- is around 10 or so branches/jumps which use labels starting from 11 to 21.
-
- If I put r[] --> The code is the same as the other two ways BUT the branch
- labels go from 25 to 35.
-
- If I put r[5] --> The particular branches go from 0 to 10.
-
- From what I know of C, r[] and r[25] should work, but I'm asking if r[5] will
- bug things up (cause memory to be overwritten somewhere and thereby cause
- a random computer lock up?).
-
- PLEASE SEND EMAIL IF YOU DO REPLY >> aabdalla@pollux.usc.edu
-
- Thanks a lot (sorry for the length...).
-
- Ahmed A. Abd-Allah
-
- PS:
- What's in the structure is irrelevant I think, but here it is anyway:
- struct coordinates
- {
- int y, x;
- }
-
-
-