Search code examples
c++environment-variablesopenvms

Openvms C++ - how to pass values to the environment


I am trying to pass values from a C++ program on VMS.

$DESCRIPTOR( lname, (char*) "A" );
$DESCRIPTOR( lvalue, (char *) "Hello World" );
lib$set_logical( &lname, &lvalue );
lib$set_symbol (&lname,&lvalue);

Should it work? If Not how do I correct it?

How can I check the return-values?

How can I check in the environment if it succeeded?

If it works, is it reliable? (Not depending on permissions etc).


Solution

  • No. Check out how $DESCRIPTOR is defined, in descrip.h: #define $DESCRIPTOR(name,string) struct dsc$descriptor_s name = { sizeof( string)-1, DSC$K_DTYPE_T, DSC$K_CLASS_S, string }

    In your example the first element of lname and lvalue will both contain 3, derived from the size of (char*), however expected is the length of the string, derived from the size of a character array.