Generating Resource Files from C Type Definitions

The rsctype utility compiles structure and union declarations (usually stored in a .mt file) and generates a resource source (.r) file containing structure and union definitions. rcomp compiles the source file and generates the resource file. The built-in functions described in this section can use the resource file.

MDL provides the C expression built-in functions to evaluate expressions at run-time. If the expressions contain references to fields contained in structures or unions, the corresponding structures and unions must be defined in a resource file.

A source program to be processed by rsctype uses C syntax for defining structures and unions. However, it cannot contain declarations that allocate space and it cannot contain executable statements.

The format of an rsctype program is typically as follows:

The syntax for a publishStructures statement, shown in the following example, is identical to the syntax for a function call.

publishStructures(structureName[, structureName, ...])

Any number of structure and union names can be included in the list of names.


This is the .mt file for

#include "basic.h"

The larger and more complex the MDL application, the more #includes and additional structures that the .mt file will contain.

Predefined macros

rsctype provides built-in macros to be used in conditional compilations. It provides all definitions provided with mcomp. It also defines the type_resource_generator variable.

rsctype, like mcomp, uses the BMAKE_OPT environment variable to obtain arguments. The string specified by BMAKE_OPT is prepended to the command line arguments before the arguments are processed. Any combination of command line arguments can be specified with the BMAKE_OPT environment variable. The options must be separated by blanks.

BMAKE_OPT generally specifies include directories. The following BMAKE_OPT definitions specify two include directories:

set BMAKE_OPT=-i$(MS)\mdl\include -Ic:\myhdrs


The command line syntax for rsctype is as follows:

rsctype [-flag, -flag,...] input-file

-flag can be one of the following:

flag description
-d<name>=<value> Define name with value as it is defined by a define statement in the source file. This option does not require =value.
-p Display preprocessor output.
-pi Trace #include statements.
-v Verbose: show the compiler's progress.
-o<filename> Specify the output filename. If this option is not specified, the output filename is created when .r is appended to the input filename prefix.
-i<dir> Add the specified directory to the list of directories searched for include files. The MDL compiler supports up to 40 include directories.

If only the file prefix is specified for the input filename, rsctype appends .mt to the name.


The type resource entries in basic.mke read:

$(o)basictyp.r : $(BaseDir) $(BaseDir)basic.h
$(o)basictyp.rsc : $(o)basictyp.r $(BaseDir)basic.h

These call the .mt.r: and .r.rsc rules in mdl.mki, which subsequently call rsctype and rcomp, respectively.

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.