home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / amiga / programm / 13083 < prev    next >
Encoding:
Internet Message Format  |  1992-09-04  |  1.4 KB

  1. Path: sparky!uunet!usc!sdd.hp.com!swrinde!dptspd!dscharfe
  2. From: dscharfe@dptspd.sat.datapoint.com (David Scharfe)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Please help me with a SAS question/problem
  5. Summary: Data alignment
  6. Message-ID: <Bu26Kr.65A@dptspd.sat.datapoint.com>
  7. Date: 4 Sep 92 14:50:50 GMT
  8. Distribution: usa
  9. Organization: Datapoint Corporation, San Antonio, TX
  10. Lines: 34
  11.  
  12. I have a SAS/C 5.10b problem.  Data structure similar to:
  13.  
  14. typedef struct Abc {
  15.    UBYTE xxx;
  16.    UBYTE q,r,t,s;
  17.    UBYTE array[13][31];
  18. } Abc;
  19.  
  20. code modifies it ala:
  21.  
  22.    abc.array[8][someValue] = someOtherValue;
  23.  
  24. The generated code does not work.  When in CPR, I watch abc.array[7] 
  25. it gets changed when executing the above for someValue <= 7.
  26.  
  27. There is an obvious alignment problem.  When I modified the code to:
  28.  
  29.    abc.array[value][someValue] = someOtherValue
  30.  
  31. CPR "mixed" source mode showed a multiplication of 'value' by 31
  32. and add of 'someValue' to get the address.  Unfortunately, when
  33. I examine the addresses of abc.array[i][0], they differ by 32.
  34. Evidently the compiler is forcing (long?)word alignment of EACH
  35. of the major array elements, but the code is not accounting for this.
  36.  
  37. Is there a compiler switch I can use to fix this, or is it a bug?
  38.  
  39. Please respond via email.
  40.  
  41. Thanks a lot,
  42.    Dave
  43.  
  44. P.S.  My apologies if this is a FAQ or RTFM; I tried the latter and
  45.       did not find anything (I suspect its in there tho!)...
  46.