Common Code Generation Options

Code generation options common to all language types are specified in the following tabbed window:

Language options, pictured above, encompass not only the output language choice, but also input specification type, encoding rules, and code compatibility options.

Certain options will be inactive (greyed out) depending on the file type selected. For example, if an XSD file is selected, the option Generate ASN.1 file based on X.694 will be active and the option Generate equivalent XML schema (XSD) file will be inactive.

Checking Generate code for all dependent imported type definitions will cause the compiler to search and generate code for modules specified in the IMPORTS statement of an ASN.1 specification.

Basic encoding rules are selected by default. Only one of BER, DER, and CER can be checked at any time. XML and XER are also mutually exclusive options.

Generated function options are shown in the following tab:

The options in this tab control which functions are generated and what modifications are made to those functions.

By default, encoding and decoding functions are generated by the compiler. If the target application does not require encoding or decoding capabilities (for example, if it is only intended to read messages and does not need to write them), unchecking the corresponding checkbox will reduce the amount of code generated.

Check Stream to modify generated encode and decode functions to use streams instead of memory buffers. This allows encoding and decoding to a source or sink such as a file or socket. Stream-based encoding and decoding cannot be combined with buffer-based.

As an aid to debugging, Print functions may also be generated. Three different different types exist: print to stdout, print to string, and print to stream. These allow the contents of generated types to be printed to the standard output, a string, or a stream (such as a file or socket).

Constraint checking may be relaxed or tightened depending on selected options. Constraints may be ignored completely by checking Do not generate constraint checks. To tighten constraints, check Enable strict constraint checks. ASN1C supports decoding and encoding values described by table constraints; checking Generate code to handle table constraints will enable this behavior. This option is a legacy option for C and C++ code generation: generating table constraints in unions is the preferred method (see the following section).

To reduce the code footprint, several other options may be selected: Generate compact code, Do not generate indefinite length processing code, Do not generate code to save/restore unknown extensions, and Do not generate types for items embedded in information objects may all be used to reduce the amount of generated code. Generate compact code cannot be used in conjunction with Generate compatible code. If XML validation is not needed, check Do not generate XML namespaces for ASN.1 modules. This will result in a smaller codebase as well as smaller output XML data. Check Generate short form of type names if generated type names are too long for the target language.

The following tab provides options for generating utility functions and applications:

The Sample Program Generation frame allows you to generate boilerplate reader and writer applications as well as randomized test data for populating a sample encoded message. The items in the Protocol Data Units frame may be used in conjunction to select the appropriate PDU data type to be used in the sample programs.

The Debugging and Event Handlers frame contains options that generate code for adding trace diagnostics and event handling hooks into generated code. It is possible to generate a type parser by generating only an event handler and no data types for the decoded messages. This grants a great deal of flexibility in handling input data at the expense of generating pre-defined functions for most common encoding and decoding tasks. Users of embedded systems may find this useful as it will shrink the output considerably while allowing them fine control over decoding procedures.

The Other Options frame contains miscellaneous modifications to code output, including type name resolution (avoiding duplicate names), date stamp removal (useful when generated code will be stored in source control), and a line item for including any new command-line features not yet represented in the GUI.