[mod.computers.vax] generating definitions files for VAX C

GWD21T@DGOGWD01.BITNET.UUCP (03/24/87)

Since the question "how can I generate .H files from VMS defintions"
has been asked so often, here's the definite command procedure to do it.
Call it C_DEFS.COM and invoke it by
        $ C_DEFS  PCBDEF        ! e.g.
to obtain PCBDEF.H . It will handle all "standard" VMS definitions
starting with "$DEFINI xxx,..." and define the same symbols that a
macro programmer has available (no structures, of course).

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> cut here >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
$! drive generation of C #define header file from MACRO definitions
$!
$! input: $'p1' in SYS$LIBRARY: STARLET or LIB .MLB
$! output: []'p1'.H
$!
$ set noon
$ open/write C_DEFS_MAR []C_DEFS.TMP
$ write C_DEFS_MAR "    .print;/*"
$ write C_DEFS_MAR "    .print; * definitions created by C_DEFS at ''f$time()'"
$ write C_DEFS_MAR "    .print; */"
$ write C_DEFS_MAR "    $''p1'"
$ write C_DEFS_MAR "    .print;/*"
$ write C_DEFS_MAR "    .print; * end of C_DEFS definitions"
$ write C_DEFS_MAR "    .print; */"
$ write C_DEFS_MAR "    .end"
$ close C_DEFS_MAR
$!
$ define/user SYS$ERROR 'p1'.H          !! MACRO puts .PRINT output here !!
$ macro/nolist/noobject SYS$INPUT+SYS$LIBRARY:LIB/LIB+SYS$DISK:[]C_DEFS.TMP
        .MACRO  $GBLINI GBL
        .MACRO  $DEF    SYM,ALLOC,SIZ
        .if     NB,SYM
SYM:
        .irp    $$$,<\SYM>
print;#define  SYM     $$$
        .endm
        .endc
        .IIF    NB,ALLOC,       ALLOC   SIZ
        .ENDM   $DEF
        .MACRO  $EQU    SYM,VAL
        SYM=VAL
        .irp    $$$,<\SYM>
print;#define  SYM     $$$
        .endm
        .ENDM   $EQU
        .MACRO  $VIELD1 MOD,SEP,SYM,SIZ,MSK
        SIZ...=1
        .IIF    NB,SIZ, SIZ...=SIZ
        .IF     NB,SYM
        MOD'SEP'V_'SYM=BIT...
        .irp    $$$,<\MOD'SEP'V_'SYM>
print;#define  MOD'SEP'V_'SYM  $$$
        .endm
        .if     nb,siz
MOD'SEP'S_'SYM=SIZ
        .irp    $$$,<\MOD'SEP'S_'SYM>
print;#define  MOD'SEP'S_'SYM  $$$
        .endm
        .endc
        .if     nb,msk
MOD'SEP'M_'SYM=<<<1@SIZ...>-1>@BIT...>
        .irp    $$$,<\MOD'SEP'M_'SYM>
print;#define  MOD'SEP'M_'SYM  $$$
        .endm
        .endc
        .ENDC
        BIT...=BIT...+SIZ...
        .ENDM   $VIELD1
        .ENDM   $GBLINI
$ xstat=$status
$!
$ delete []C_DEFS.TMP;
$ exit xstat
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> cut here >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

W.J.Moeller, GWDG, D-3400 Goettingen, F.R.Germany  <GWD21T@DGOGWD01>
                                                  Phone +49 551 201516