define_format

Name

Property define_format -- Control how an option's value will appear in the configuration header file.

Synopsis

cdl_option <name> {
    define_format <format string>
    …
}

Description

For active options with the data flavor, and for active and enabled options with the booldata flavor, the configuration tools will normally generate two #define's in the package's configuration header file. These take the following forms:

#define <name> <value>
#define <name>_<value>

The define_format property can be used to control exactly what appears as the value for the first of these #define's. For example, the following can be used to output some configuration data as a C string:

cdl_option <name> {
    …
    define -format="\\\"%s\\\"" <symbol>
}

The implementation of define_format involves concatenating the Tcl command format, the format string, and the string representation of the option's value, and evaluating this in a Tcl interpreter. Therefore the format string will be processed twice by a Tcl parser, and appropriate care has to be taken with quoting.

The second #define will be generated only if is a valid C preprocessor macro symbol, and is not affected by the define_format property. Also, the property is only relevant for options with the data or booldata flavor, and cannot be used in conjunction with the no_define property since it makes no sense to specify the format if no #define is generated.

Caution

Because the Tcl interpreter's format command is used, this property is subject to any problems with the implementation of this in the Tcl library. Generally there should be no problems with string data or with integers up to 32 bits, but there may well be problems if 64-bit data is involved. This issue may be addressed in a future release.

Example

cdl_option CYGNUM_UITRON_VER_ID     {
    display       "OS identification"
    flavor        data
    legal_values  0 to 0xFFFF
    default_value 0
    define_format "0x%04x"
    description   "
        This value is returned in the 'id'
        field of the T_VER structure in
        response to a get_ver() system call."
}

See Also

Properties define, define_header, define_proc, if_define and no_define.