HP OpenVMS Systems

Application access to system parameters?

When compiling a C program, is there any way to use a sysgen parameter as a
symbol in the program? As an example, creating a table of connections using
CHANNELCNT as a parameter for the size of an array, or the maximum number of
allowable connections.
The current arch used for this is a Alpha VMS 7.2 systems with TCPIP V5.0a
on it. Thanks!

The Answer is :

The OpenVMS Wizard strongly encourages reading the required value(s)
dynamically, and then sizing the various resulting data structure(s)
dynamically. An example is attached below.
The value can also be read at compile-time using the attached DCL or
similar approach. As the value of the OpenVMS CHANNELCNT system
parameter can obviously and easily change between the time the program
is initially compiled and when it is finally run, the OpenVMS Wizard
does not recommend this approach. An example of using this approach
is shown below.
The application could also be linked directly against the OpenVMS
executive, acquiring the current value as part of the LINK. For the
same reasons the OpenVMS Wizard does not recommend compile-time access
and for reasons of avoiding dependence on particular OpenVMS version(s),
the OpenVMS Wizard does not recommend this approach. No example of
this approach is provided here.
Determining the value of CHANNELCNT at the time of compilation:
$ channelcnt = f$getsyi("CHANNELCNT")
$ cc/define="CHANNELCNT=''channelcnt'" file.c,...
Determining the value of CHANNELCNT at run-time:
#include <lib$routines.h>
#include <syidef.h>
#include <stsdef.h>
#include <stdlib.h>
main()
{
int RetStat;
int ChannelCnt = 0;
int i;
struct Foo
{
unsigned short int IOChannel;
unsigned short int Stuff;
unsigned long int OtherStuff;
} *Bar;
RetStat = lib$getsyi(&SYI$_CHANNELCNT,&ChannelCnt);
Bar = calloc( ChannelCnt, sizeof( struct Foo ));
for (i = 0; i < ChannelCnt; i++ )
(Bar+i)->Stuff = i;
return 1;
}