home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / vms / 20172 < prev    next >
Encoding:
Text File  |  1992-12-31  |  2.5 KB  |  68 lines

  1. Newsgroups: comp.os.vms
  2. Path: sparky!uunet!wupost!spool.mu.edu!agate!usenet.ins.cwru.edu!gatech!destroyer!cs.ubc.ca!mprgate.mpr.ca!vli
  3. From: vli@mpr.ca (Vincent Li)
  4. Subject: Unbound array in C
  5. Message-ID: <1993Jan1.004614.10365@mprgate.mpr.ca>
  6. Sender: news@mprgate.mpr.ca
  7. Organization: MPR Teltech Ltd., Burnaby, B.C., Canada
  8. Date: Fri, 1 Jan 93 00:46:14 GMT
  9. Lines: 57
  10.  
  11. OK, this may or may not be the right place, but seems to be the best I could
  12. find. I've looked up the VAX C reference, VAX Pascal reference, and even
  13. descrip.h, but couldn't figure this one out. May be I'm not looking in the
  14. right places. Here's my question: How do you call (VAX) Pascal from (VAX) C
  15. where one of the parameters is an unbounded(?) array?
  16.  
  17. What I'm trying to do is to create essentially a .h interface to allow me
  18. to call some Pascal functions from C programs. One of the Pascal function
  19. is defined as:
  20.  
  21. TYPE 
  22.    a_string = packed array [1..132] of char;
  23.  
  24. FUNCTION get_all_switch(var name : array [$l..$u:integer] of a_string
  25.                        ):integer;
  26.  
  27. The corresponding C function would be:
  28. int get_all_switch(desc);
  29. where desc is a pointer to a descriptor structure.
  30.  
  31. typedef struct {
  32.         struct dsc$descrip_a arr_dsc;
  33.         char   *a0;
  34.         long dsc$l_m[2];
  35.         struct {
  36.          long dsc$l_l;
  37.          long dsc$l_u;
  38.          } des$bounds[2];
  39. } array_dsc;
  40.  
  41. array_dsc *desc;
  42.  
  43. and the actual array as:
  44. typedef char a_string[132];
  45. a_string name[200];
  46.  
  47. Now, what I am having problem with is how do you set up the descriptor
  48. sturcture? I tried to follow the instructions in the C reference, but can't
  49. get it to work. I think it is correct to use the struct dsc$descrip_a
  50. for the descriptor. I defined the dimension to be 2, since this is an array
  51. of strings. When I call the function, I defined a C array of array[200]
  52. and passed in 0 for the lower bound and 199 for the upper bound (I also tried
  53. using 1 and 200, which does not work either). Running from the debugger, I
  54. seem to be a couple of bytes off or something in the descriptor structure.
  55.  
  56. So, how should I fill in the descriptor block in the call? Am I missing
  57. something? I'm pretty sure I got all the & in the right places. (I even tried
  58. just about all possible combinations with and without.) It either does a
  59. dump or returns nothing in the array.
  60.  
  61. Thanks in advance.
  62.  
  63. -- Vince
  64.  
  65. ---------------------------------------
  66. vli@mprgate.mpr.ca        |-) It works well under pressure: Another thing
  67.                           |-] you can say about your pillow. -- Mr Boffo
  68.