Page 1 of 1

OpenVMS header files and descrip.h

Posted: Sat Jul 20, 2019 12:22 pm
by ajbrehm
I copied the OpenVMS header files from DKA0:[SYS0.SYSCOMMON.DECC$LIB.REFERENCE.SYS$STARLET_C] which appears to work. However, I appear to be missing a file DESCRIP.H.

What did I misunderstand?

Added in 3 hours 32 minutes 4 seconds:
I noticed when I create a file test.c with an #include <descrip.h> on the VMS system, cc does not complain about a non-existing descrip.h. But I cannot find a descrip.h anywhere on the VMS file system.

When I write a C file in Visual Studio Code and include a fake descrip.h (which I created), the call to $DESCRIPTOR() works (but is marked as an error in the IDE). The C file then compiles on the VMS system and the system call works.

Specifically I did a

$DESCRIPTOR(tt, "SYS$OUTPUT");
unsigned short int channel;
sys$assign(&tt, &channel, 0, 0, 0);
char *s = "Hello from sys$qiow!\n";
int length=strlen(s);
sys$qiow(0, channel, IO$_WRITEVBLK, &iosb, 0, 0, s, length, 0, 0, 0, 0);

The "tt" in $DESCRIPTOR is marked by the IDE as an error since $DESCRIPTOR does not exist (since descrip.h does not exist). But it compiles and runs.

I am imagining that the parameter after the string (length) is indeed the length of the string to output. It appears to work. If I make the parameter bigger, the system call outputs lots of question marks after my string s.

Where is descrip.h supposed to be and why does cc on VMS find it even though dir [...] does not?

Re: OpenVMS header files and descrip.h

Posted: Sun Jul 21, 2019 5:50 am
by ajbrehm
In the mean time someone who must have read this forum sent me a note (via my Web site, so I don't know who he was) explaining that the header files in [.DECC$LIB.REFERENCE] are likely out of date and that cc uses DECC$RTLDEF.TLB. I have to extract the header files from there to use them with VS Code.

(I think the VMS-IDE extension should really come with all the necessary header files.)

Added in 4 hours 5 minutes 2 seconds:
I extracted DESCRIP from DECC$RTLDEF.TLB and added it to my existing directory of header files as DESCRIP.H. I hope this is all I need.

Re: OpenVMS header files and descrip.h

Posted: Mon Jul 22, 2019 1:16 am
by martinv
Quoting from the output of the HP C installation procedure:
The C Runtime Library headers and Starlet headers are installed as a Text Library (.TLB). The traditional text form of the headers (.H files) are also provided (for reference purposes only) in the directories: SYS$COMMON:[DECC$LIB.REFERENCE.DECC$RTLDEF] and SYS$COMMON:[DECC$LIB.REFERENCE.SYS$STARLET_C].
DESCRIP.H is in SYS$COMMON:[DECC$LIB.REFERENCE.DECC$RTLDEF]

Re: OpenVMS header files and descrip.h

Posted: Mon Jul 22, 2019 3:24 am
by ajbrehm
SYS$COMMON:[DECC$LIB.REFERENCE.DECC$RTLDEF]
This directory is empty.

I didn't install HP C. I use the "hobbyist" student image.

Re: OpenVMS header files and descrip.h

Posted: Mon Jul 22, 2019 4:22 am
by martinv
Okay, then extracting the module from DECC$RTLDEF.TLB was the right thing to do.
To extract all headers to the designated reference directory, a small DCL program should do the job:

Code: Select all

$ rtldef = "SYS$LIBRARY:DECC$RTLDEF.TLB"
$ dest = "SYS$COMMON:[DECC$LIB.REFERENCE.DECC$RTLDEF]"
$
$ create/directory 'dest'
$
$! get list of all the module names
$ library /list=libr_list.out 'rtldef'
$
$ close/nolog in
$ open/read /end=done_read/error=err in libr_list.out
$
$! skip the text library header
$header_loop:
$ read /end=done_read/error=err in mod_name
$ if ("''mod_name'" .nes. "") then goto header_loop
$
$! now walk the list and extract each one
$loop:
$ read /end=done_read/error=err in mod_name
$ library /extract="''mod_name'"/output='dest''mod_name'.H 'rtldef'
$! files were being created without world read+execute privs
$ set protection=(w:re) 'dest''mod_name'.H
$ goto loop
$done_read:
$ delete /nolog libr_list.out;*
$err:
$ close in
$ exit
(This is based on DECC$EXTRACT_CLD.COM from the C PCSI kit)

Re: OpenVMS header files and descrip.h

Posted: Mon Jul 22, 2019 4:25 am
by marty.stu
I extracted DESCRIP from DECC$RTLDEF.TLB and added it to my existing directory of header files as DESCRIP.H. I hope this is all I need.
Hi ajbrehm,

Yes, you used the right method and don't need anything else. To get more information about how the C/C++ compiler finds header files and where they are stored, you can view the following section of the online help: http://mx.isti.cnr.it/cgi-bin/conan?key ... _DIRECTORY

Re: OpenVMS header files and descrip.h

Posted: Mon Jul 22, 2019 7:47 am
by ajbrehm
For completeness' sake, this is the result of my attempts:

http://desertpenguin.org/blog/hello-openvms.html