home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / c / 11717 < prev    next >
Encoding:
Text File  |  1992-07-29  |  2.3 KB  |  67 lines

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