home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.vms
- Path: sparky!uunet!wupost!spool.mu.edu!agate!usenet.ins.cwru.edu!gatech!destroyer!cs.ubc.ca!mprgate.mpr.ca!vli
- From: vli@mpr.ca (Vincent Li)
- Subject: Unbound array in C
- Message-ID: <1993Jan1.004614.10365@mprgate.mpr.ca>
- Sender: news@mprgate.mpr.ca
- Organization: MPR Teltech Ltd., Burnaby, B.C., Canada
- Date: Fri, 1 Jan 93 00:46:14 GMT
- Lines: 57
-
- OK, this may or may not be the right place, but seems to be the best I could
- find. I've looked up the VAX C reference, VAX Pascal reference, and even
- descrip.h, but couldn't figure this one out. May be I'm not looking in the
- right places. Here's my question: How do you call (VAX) Pascal from (VAX) C
- where one of the parameters is an unbounded(?) array?
-
- What I'm trying to do is to create essentially a .h interface to allow me
- to call some Pascal functions from C programs. One of the Pascal function
- is defined as:
-
- TYPE
- a_string = packed array [1..132] of char;
-
- FUNCTION get_all_switch(var name : array [$l..$u:integer] of a_string
- ):integer;
-
- The corresponding C function would be:
- int get_all_switch(desc);
- where desc is a pointer to a descriptor structure.
-
- typedef struct {
- struct dsc$descrip_a arr_dsc;
- char *a0;
- long dsc$l_m[2];
- struct {
- long dsc$l_l;
- long dsc$l_u;
- } des$bounds[2];
- } array_dsc;
-
- array_dsc *desc;
-
- and the actual array as:
- typedef char a_string[132];
- a_string name[200];
-
- Now, what I am having problem with is how do you set up the descriptor
- sturcture? I tried to follow the instructions in the C reference, but can't
- get it to work. I think it is correct to use the struct dsc$descrip_a
- for the descriptor. I defined the dimension to be 2, since this is an array
- of strings. When I call the function, I defined a C array of array[200]
- and passed in 0 for the lower bound and 199 for the upper bound (I also tried
- using 1 and 200, which does not work either). Running from the debugger, I
- seem to be a couple of bytes off or something in the descriptor structure.
-
- So, how should I fill in the descriptor block in the call? Am I missing
- something? I'm pretty sure I got all the & in the right places. (I even tried
- just about all possible combinations with and without.) It either does a
- dump or returns nothing in the array.
-
- Thanks in advance.
-
- -- Vince
-
- ---------------------------------------
- vli@mprgate.mpr.ca |-) It works well under pressure: Another thing
- |-] you can say about your pillow. -- Mr Boffo
-