TOP

ASN.1/C++ Compiler Options Reference

Applies to: ASN.1/C++ 6.5

-1990 | -2015

Specifies the ASN.1 version used in the input ASN.1 specification file.

The -1990 option indicates that the ASN.1 specification conforms only to the 1990 version of ASN.1. The ASN.1/C++ compiler fully supports ASN.1:1990, including these features:

  • Macro notation
  • ANY DEFINED BY
  • Named types without identifiers

The -2015 option indicates that the ASN.1 specification conforms to the 2015 version of ASN.1. The ASN.1/C++ compiler supports these ASN.1:2015 features:

  • Automatic tagging
  • Information object classes
  • Component relation constraints
  • Table constraints
  • Parameterization
  • Version brackets
  • Enhanced subtype notation capabilities
  • TIME, OID-IRI, and RELATIVE-OID-IRI types

Remarks

The ASN.1 Compiler lets you mix the 1990 and 2015 syntaxes, but issues warnings since this behavior is not allowed by X.680 (2015) ISO/IEC 8824-1:2015.

When using ASN.1:2015 syntax, the compiler complains when:

  • Components of a SET, SEQUENCE, or CHOICE do not have an identifier.
  • Colons (":") are not included in ANY or CHOICE values.
  • A value reference (defined value) appears before the DEFINITIONS keyword that signals the start of an ASN.1 module or appears within an object identifier used to define an ASN.1 module.

The -1993, -1994, -1997, -2002, and -2008 compiler options are equivalent to the -2015 option.

Default Behavior

The compiler starts out in neutral mode, expecting either ASN.1 version. Once syntax unique to ASN.1:1990 or ASN.1:2015 is detected, the compiler exits neutral mode and checks for conformance to the detected version, generating messages for any violations. However, starting in neutral mode could cause a longer ASN.1 specification debugging cycle, especially when creating new ASN.1 specifications.

↩Options Index


-allow BadCase

This option restores old, incorrect compiler behavior or instructs the compiler to accept incorrect ASN.1 syntax, as specified by the argument. Use with caution and only when absolutely necessary.

The option takes a single argument, but can be specified more than once when multiple compatibility options are used, for example,

asn1 foo.asn -allow BadValues -allow BadSerialFROM 

Arguments

-allow BadExplicitAutomaticTagging

Instructs the ASN.1/C++ compiler to use explicit automatic tagging not only for untagged but also for tagged CHOICE types, open types, and "DummyReference" types, based on the interpretation of clause 31.2.7 c of the X.680 2002 ASN.1 standard.

In the following example, if -allow BadExplicitAutomaticTagging is specified, the compiler uses explicit automatic tagging for the ch field that has the tagged CHOICE type. If -allow BadExplicitAutomaticTagging is not specified, the compiler uses implicit tagging for this field.

B4114 DEFINITIONS AUTOMATIC TAGS ::= BEGIN
   Seq ::= [65] SEQUENCE { ch Cho }
   Cho ::= [65] CHOICE { b BOOLEAN }
   s Seq ::= { ch b : TRUE }
END
-allow BadValues

This option is implied by the default -relaxedMode option and instructs the ASN.1 Compiler to continue the current compile when a content error is found in the value notation of restricted character strings (i.e., NumericString, PrintableString, and VisibleString), OBJECT IDENTIFIERs, or extensible types with missing mandatory extension additions.

Example

myPhoneNumber   NumericString      ::= "(800) 555-1212 EXT-6"
myObjectID      OBJECT IDENTIFIER  ::= {0 26}

This value notation will cause the ASN.1 Compiler to exit with an error message, unless –allow BadValues is specified.
According to the ASN.1 standard, the NumericString type allows only numbers (0-9) and white space in its contents. The OBJECT IDENTIFIER type allows no value larger than 4 for its second node.

Remarks

The compiler does not truncate BIT STRING, restricted string, or OCTET STRING values defined with extensible size constraints to the sizes defined by those constraints.

To instruct the ASN.1 Compiler to treat the errors as warnings, use the -ignoreError compiler option, which is equivalent to the -allowBadValues compiler option.

This option also instructs the ASN.1 Compiler to issue the A1007W warning message, instead of the A1006E error message in some cases of type-value mismatch in ENUMERATED, SET, SEQUENCE, or CHOICE value assignments. For ENUMERATED types, differences in the named values set are allowed. For SET, SEQUENCE, and CHOICE types, differences in field tags and in the extension marker position are allowed.

For ENUMERATED types, the option allows names from one ENUMERATED type to be used in the value of a different ENUMERATED type, as shown in the following example:

Enum1 ::= ENUMERATED {blue(0), red(1)}
Enum2 ::= ENUMERATED {green(3)}

var Enum1 ::= green

For SET, SEQUENCE, and CHOICE types, the option allows a difference in the tags of the fields and in the position of the extension marker.

-allow BadSerialFROM

Restores the old ASN.1 Compiler behavior concerning serial application of a permitted alphabet constraint to a type; only the last such constraint is considered when an effective permitted alphabet for the type is calculated.

Example

M DEFINITIONS ::= BEGIN
    S ::= PrintableString (FROM("ABC"))  (FROM("DEF"))
END

The compiler normally issues an error for the example because the permitted alphabet is empty. However, if –allow BadSerialFROM is specified no error is issued and the alphabet "DEF" is used for S.

-allow Bad6.0Extensions

Instructs the ASN.1 Compiler to not report a tag conflict for an untagged extensible CHOICE inside an extensible SEQUENCE.

Example

M DEFINITIONS EXPLICIT TAGS ::= BEGIN
    S ::= SEQUENCE {
        a INTEGER,
        c C OPTIONAL,
        ...,
        e BMPString,
        ...
    }

    C ::= CHOICE {
        c1 [0] INTEGER,
        c2 [1] IA5String,
        ...
    }
END

When -allow Bad6.0Extensions is not specified, the compiler issues this error:

"test.asn", line 4 (M): A0554E: Extension marks conflict in type S: extension marker and element 'c' (line 4).
-allow MixedCaseForSomeBuiltInTypesNames

This option is implied by the default -relaxedMode option. It instructs the compiler to accept mixed-case names for some ASN.1 built-in types, provided that types with these names are not already defined in the ASN.1 input.

This option currently supports mixed-case names for these built-in types:

  • INTEGER without named numbers
  • BOOLEAN
  • NULL
  • Restricted character string: UTF8String, NumericString, PrintableString, TeletexString, T61String, VideotexString, IA5String, GraphicString, VisibleString, ISO646String, GeneralString, UniversalString, BMPString
  • Time: TIME, DATE, TIME-OF-DAY, DATE-TIME, DURATION
  • GeneralizedTime and UTCTime
  • ObjectDescriptor

Example

M DEFINITIONS ::=  BEGIN
 Type ::= IA5STRING
 value Type ::= "abc"
END

When -allow MixedCaseForSomeBuiltInTypesNames is specified, the compiler assumes that IA5STRING is the IA5String built-in type.

-allow named

Restores the old ASN.1 Compiler behavior concerning serial application of a permitted alphabet constraint to a type; only the last such constraint is considered when an effective permitted alphabet for the type is calculated.

-allow namedBitThatExceedsConstraint

When a named bit is larger than the size of a BIT STRING, the ASN.1 Compiler issues an error and stops. This flag causes the compiler to issue a warning instead.

-allow UnderscoresInAsn1Names

This option is implied by the default -relaxedMode option. It instructs the ASN.1 Compiler to accept ASN.1 names that contain the underscore character ("_") after the initial character.

Example

M DEFINITIONS ::= BEGIN
  Some_Type ::= INTEGER
END

If -allow UnderscoresInAsn1Names is not specified the compiler reports the following errors:

"test.asn", line 2 (M): A1271E: The low line character ('_') is not among the
permitted characters for ASN.1 names. Please use the '-allow UnderscoresInAsn1Names'
command line option to force the compiler to accept such invalid names.
  Some_Type ::=INTEGER
      ^
-allow universaltags

Instructs the ASN.1 Compiler to accept UNIVERSAL class tags that are normally prohibited. This option is enabled by default in trial versions of the ASN.1 Compiler.

Use UNIVERSAL class tags for

  • IMPLICIT tags whose number matches a built-in type tag.
  • CHARACTER STRING and OCTET STRING types with a specified tag number that matches one of the restricted character string types.

Any other UNIVERSAL tags are rejected.

Example

If you use a UNIVERSAL tag for a CHARACTER STRING or OCTET STRING type, the compiler will redefine the type to a restricted character string type according to its tag number.

M DEFINITIONS IMPLICIT TAGS ::= BEGIN
        B-ignore ::= [UNIVERSAL 1] IMPLICIT BOOLEAN

        CS-ignore ::= [UNIVERSAL 29] CHARACTER STRING
        OS-ignore ::= [UNIVERSAL 4] OCTET STRING

        GT-ignore ::= [UNIVERSAL 24] GeneralizedTime
        UTCT-ignore ::= [UNIVERSAL 23] UTCTime
        U8-ignore ::= [UNIVERSAL 12] UTF8String
        BMP-ignore ::= [UNIVERSAL 30] BMPString

        CS-U8 ::= [UNIVERSAL 12] CHARACTER STRING
        OS-U8 ::= [UNIVERSAL 12] OCTET STRING

        CS-BMP ::= [UNIVERSAL 30] CHARACTER STRING
        OS-BMP ::= [UNIVERSAL 30] OCTET STRING  
END

In this example, the CS-U8 type is treated as a UTF8String. The following warning message is issued:

"test.asn", line 12 (M): A1163W: OSS has relaxed the standards to allow the
definition of a type with the tag [UNIVERSAL 12] resulting in 'CHARACTER STRING'
to be redefined to 'UTF8String'.  This is normally an invalid ASN.1.
        CS-U8 ::= [UNIVERSAL 12] CHARACTER STRING
                               ^

See Also

↩Options Index


-allowBadValues

This option is equivalent to the –allow BadValues compiler option.


-assignments

Instructs the ASN.1 Compiler to process type and value assignments found outside defined input modules.

Example

 Module1 DEFINITIONS ::= BEGIN
    MyInt ::= INTEGER
 END

    ExtraModularType ::= INTEGER

 Module2 DEFINITIONS ::= BEGIN
    MyBit ::= INTEGER
 END
  

If the -assignments option is not specified, the ASN.1 Compiler issues an error because ExtraModularType is outside of a BEGIN-END ASN.1 module.

Default Behavior

The –assignments option is turned off.

↩Options Index


-autoEncDec

Allows automatic encoding and decoding of open types when runtime constraint checking is disabled. Encoding and decoding is faster and more efficient when constraint checking is disabled.

Remarks

When the –autoEncDec option is not specified, automatic encoding and decoding of open types will not be permitted when constraint checking is turned off (e.g., –noConstraints is specified), even when the AUTOMATIC_ENCDEC runtime flag is specified.

Be sure to set the AUTOMATIC_ENCDEC runtime flag to enable automatic encoding and decoding of open types, even when -autoEncDec is specified on the command-line.

Default Behavior

The –autoEncDec option is turned off.

See Also

↩Options Index


-ber -der -cer -per -uper -xer -cxer -exer -oer -coer -json

Specifies the encoding rules available at runtime:

  • Basic Encoding Rules (-ber)
  • Distinguished Encoding Rules (-der)
  • Canonical Encoding Rules (-cer)
  • Aligned Packed Encoding Rules (-per)
  • Unaligned Packed Encoding Rules (-uper)
  • Basic XML Encoding Rules (-xer)
  • Canonical XML Encoding Rules (-cxer)
  • Extended XML Encoding Rules (-exer)
  • Octet Encoding Rules (-oer)
  • Canonical Octet Encoding Rules (-coer)
  • JavaScript Object Notation (JSON) Encoding Rules (-json)

Any combination of these options can be specified; all will be available at runtime.

Remarks

The options have the following precedence: (1) -ber, (2) -per, (3) -der, (4) -uper, (5) -xer, (6) -cxer, (7) -cer, (8) -exer, (9) –oer, (10) –coer, (11) –json. So, when more than one option is specified, the one that is first in this list is used by default. For example, if you specify -der -per -xer, the PER encoding rules will be used by default, but you can switch to DER and XER at runtime.

When one of these command-line options is specified, the encoding rules available at runtime vary depending on the encoder/decoder library in use. This is summarized in the following table:

-ber -per -der -uper -xer -cxer -cer -exer -oer -coer -json
SOED BER PER
UPER
DER
BER
UPER
PER
XER XER
CXER
CER
BER
E-XER OER C-OER
OER
JSON
TOED BER PER DER UPER XER CXER N/A E-XER OER C-OER JSON
LED BER PER
UPER
DER
BER
UPER
PER
XER XER
CXER
N/A E-XER OER OER
C-OER
JSON

To switch to a different set of available encoding rules at runtime, simply call the setEncodingRules() method of the OssControl class, for example,

control.setEncodingRules(OSS_DER); /* switch to DER */

When you specify the -xer, -cxer, or -exer option, -debug is also enabled. The -noDebug option along with the -xer, -cxer, or -exer option has no effect.

Default Behavior

The -ber option is implied.

↩Options Index


-commandFile commandFileName

Specifies the name of the text-file containing command-line options for the current compile. This option is useful on systems that do not permit long command lines or do not support command-line continuation characters. Options contained in the file are treated as if they were entered on the command line. The file can consist of several lines; the compiler will read all of them.

Example

The following command will compile input.asn using the command-line options included in the tenLinesOfOptions.opt text file:

asn1 input.asn -commandFile tenLinesOfOptions.opt

Remarks

Command files can contain comments. The "--" characters specify the beginning of a comment. They can be placed anywhere on the line. The comment continues until a subsequent "--" is reached or the line ends.

Default Behavior

The -commandFile option is turned off.

↩Options Index


-compat version# | option

Instructs the compiler to generate header and .cpp files compatible with previous versions of the OSS ASN.1 Compiler.

This option takes a single operand or flag, and can be specified more than once.

Example

asn1cpp foo.asn -compat v3.0 -compat UTF8StringasBMPString

Remarks

For a list of flags that can be used with the -compat option, see Backward Compatibility.

OSS does not guarantee compatibility between versions of the ASN.1 Tools released more than 10 years apart.

↩Options Index


-constraints | -noConstraints

The -constraints option instructs the ASN.1/C++ compiler to generate information for runtime constraint checking and write it into the control table.

The -noConstraints option specifies that no information for runtime constraint checking should be generated and written into the control table; this results in a smaller control table and faster execution.

Remarks

To disable runtime constraint checking when the -constraints option is present, specify the NOCONSTRAIN encoder or decoder flag.

When neither -constraints nor -noConstraints is explicitly specified, the Time-Optimized Decoder (TOED) checks the encoded size of a size-constrained string to ensure it does not exceed the upper bound, and reports an error if it does. This check is to prevent the allocation of a possibly huge amount of memory for an incorrectly encoded length, without incurring the performance penalty of full constraint checking.

Default Behavior

For TOED: -noConstraints

For SOED and LED: -constraints

See Also

↩Options Index


-controlFile [C++ FileName]

Instructs the ASN.1 Compiler to generate a control table for the encoder/decoder, and optionally specify the name of the output C++ file. The control table information in the output C++ file is used by the encoder/decoder at runtime.

Remarks

This option can be followed by an operand to explicitly name the output C++ file. If the operand is absent and the -output option is not used, the name for the output C++ file will be derived from the last command-line input filename with a .cpp suffix appended.

Default Behavior

The –controlFile option is implied without an operand.

See Also

↩Options Index


-debug | -noDebug

Enables or disables writing debug information into the C++ file.

Remarks

When -debug is turned on, the encoder/decoder can produce descriptive messages that include the names of ASN.1 identifiers and Defined Types. The identifier names are used by the ASN.1/C++ runtime routines that print PDU objects and convert ASN.1/C++ objects to and from ASN.1 value notation; without these names, the runtime prints <anonymous> instead.

Default Behavior

The -debug option is implied.

↩Options Index


-decodeOnly | -encodeOnly

Instructs the compiler to generate decoding-only or encoding-only routines for the Time-Optimized Encoder/Decoder.

Remarks

These options have no effect when you use the Space-Optimized Encoder/Decoder and do not specify -xer or -cxer, since the information generated into the control table is used for both encoding and decoding. However, if you do specify -xer or -cxer, then these options will be effective and can be used to reduce the amount of Space-Optimized library code linked to your final application.

Default Behavior

Both encoder and decoder routines are generated.

↩Options Index


-designerWarnings

Instructs the ASN.1 Compiler to generate additional warning messages for protocol designers writing ASN.1 specifications.

Remarks

Additional warning messages are issued if

  • The -per or -uper option is specified, but a SET, SEQUENCE, or CHOICE type that contains a single component and no extension marker is found. When using PER, having an inextensible structured type with only one field is inefficient.
  • The -per or -uper option is specified and there is more than one unreferenced type in the root module. This could make determining the encoded type difficult when decoding, since PER encodings have no tag information. In this case, the type being decoded should be explicitly specified.
  • There is no defined object set used in a table constraint when ObjectSetFromObject notation is used for dummy information object sets.
  • An information object CLASS definition includes a WITH SYNTAX clause, but an optional element is not enclosed in square brackets ("[]").
  • A WITH COMPONENTS subtype constraint has the OPTIONAL or ABSENT keyword applied to a type defined with a DEFAULT value in the input ASN.1 specification.

Default Behavior

The -designerWarnings option is turned off.

↩Options Index


-disableSharing

Instructs the ASN.1 Compiler not to search the input specification for identical types from which to create shared classes.

Remarks

Normally, when the same ASN.1 type (or types similar enough to use the same ASN.1/C++ representation class) occurs multiple times in the input specification, the ASN.1/C++ compiler generates one class and several typedef declarations to minimize the generated code size. If –disableSharing is specified, the compiler generates several identical classes instead.

Default Behavior

The -disableSharing option is turned off.

↩Options Index


-dtd

Instructs the ASN.1 Compiler to generate multiple Data Type Definitions (DTD) files, one for each PDU.

Remarks

The names of the DTD files will be the same as the PDU type names, with the .dtd suffix added, unless the OSS.DTD directive specifies a different name. Any name aliasing using the ASN1.Nickname directive affects the generated DTD filename.

Default Behavior

The -dtd option is turned off.

See Also

↩Options Index


–enablePartialDecode

Instructs the ASN.1 Compiler to enable partial decoding, in addition to standard decoding.

Remarks

Encoding is not affected.

Partial decoding is supported only by the TOED runtime. That is, -enablePartialDecode cannot be used together with the -soed option.

When -enablePartialDecode is specified, the <module_name>_Callback class is incorporated into the generated header and code files; other definitions are unaffected.

XER, CXER, E-XER, and JSON do not support partial decoding and cannot be used with the -enablePartialDecode option.

Default Behavior

The -enablePartialDecode option is turned off.

See Also

↩Options Index


-errorFile errorFileName

Instructs the compiler to redirect all ASN.1 Compiler messages to an error file. This is useful on platforms where you cannot easily redirect stdout and stderr to a file.

Remarks

If an error is detected on the command line before you specify the -errorFile option, the message is written to stdout instead of the error file. All command-line error messages are written to the error file when -errorFile is the first option on the command line, as shown in the following example:

asn1cpp -errorFile myErrs.err foo.asn

If errorFileName lacks an extension, the .err extension is added. If it has the .asn extension, it is replaced by .err; otherwise, errorFileName keeps the extension you specified.

Default Behavior

The -errorFile option is turned off.

↩Options Index


-externalname projectExternalName

Specifies the name of the ASN.1 project. The ASN.1/C++ compiler uses projectExternalName to begin the names of the universal PDU and control object classes generated for the input ASN.1 specification.

Example

asn1cpp –external Bar foo.asn

From this command line, the compiler will generate a universal PDU class named Bar_PDU and a control object class named Bar_Control.

Default Behavior

The ASN.1 project name is the same as the last input filename on the command line, without the .asn extension.

↩Options Index


-genDirectives genDirFileName

Instructs the ASN.1 Compiler to generate a .gen file that captures all directives from the ASN.1 input file as well as the directives for compiler-created names, for example, _setof1.

Remarks

The optional genDirFileName operand specifies the name of the .gen file. If absent, then the filename defaults to the last input filename on the command line, with a .gen extension rather than .asn.

Default Behavior

The -genDirectives option is turned off.

See Also

↩Options Index


-headerFile headerFileName

Specifies the name of the generated header file that represents the ASN.1 specification in C++.

Remarks

The optional headerFileName operand explicitly names the output header file. If absent and the -output option is not used, then the filename is the same as the last input filename on the command line, with an .h extension rather than .asn.

See Also

↩Options Index


-help

Displays a summary of all valid command-line options.

Example

By entering asn1cpp –help you can obtain a summary of valid command-line options:

OSS ASN.1/C++ Compiler Version 6.5
Copyright (C) 2017 OSS Nokalva, Inc.  All rights reserved.

Compiler parameters: (.D. indicates default)
  <input> <...input> . one or more ASN.1 input files

  -cont <ctrlfile> ... generate C++ file into <ctrlfile>
  -soed            ... generate control table for SOED encoder/decoder
  -toed            .D. generate time-optimized encoder/decoder code
  -notoed          ... do not generate time-optimized encoder/decoder code
  -lean            ... generate universal control table for LEAN/SOED
                       encoder/decoder
  -syntax          ... perform syntax checking only

  -h <headerfile>  .D. generate C include file into <headerfile>
  -output name     ... use name for output file names
  -nooutput        ... do not generate output files, same as syntaxonly.
  -errorfile file  ... write all messages to 'file' instead of stdout/stderr
  -namespace name  ... use namespace for generated classes
  -list <listfile> ... generate an ASN.1 combined listing into 'listfile'
  -nolist          .D. do not generate an ASN.1 combined listing
  -mod <listfile>  ... generate single ASN.1 module listings into 'listfile'
  -nomod           .D. do not generate single ASN.1 module listings
  -gendir <genfile>... generate list of directives into <genfile>

  -shortennames    ... shorten generated variable names to be 31 bytes max
  -noshortennames  .D. do not shorten generated names
  -uniquepdu       .D. check that pdu id's are unique 
  -nouniquepdu     ... do not check that pdu id's are unique 
  -prefix id       ... prefix variables with unique id
  -externalname name . external variable name of encoder/decoder info

  -constraints     .D. check constraints at runtime
  -restrictedConstraintChecking
                   ... do not ignore the OSS.NoConstrain directive
                       when -constraints is specified
  -noconstraints   ... do not check constraints at runtime
  -encodeonly      ... generate only encoder routines
  -decodeonly      ... generate only decoder routines
  -test            ... generate a program to encode/decode ASN.1 values
  -notest          .D. do not test encoding/decoding of all ASN.1 values
  -debug           .D. issue detailed trace data and error messages
  -nodebug         ... do not issue detailed trace data and error messages
                       to slightly improve CPU performance


  -warning         ... allow warning messages
  -nowarning       ... suppress warning messages
  -suppress msg#   ... suppress a specific message
  -ignoresuppress  ... ignore the SUPPRESS directive (display all messages)
  -verbose         ... display compilation progress messages
  -noverbose       .D. do not display compilation progress messages
  -pedantic        ... rigorously check all modules
  -nopedantic      .D. rigorously check only the root module(s)
  -relaxedMode     .D. automatically select command-line options that
                       result in relaxed compiler behavior, for example,
                       -allowBadValue, -noWarning, etc.
  -norelaxedMode   ... automatically select command-line options that
                       result in strict compiler behavior
  -informatory     ... allow informatory messages
  -noinformatory   ... suppress informatory messages
  -ignoreError msg#... ignore a specific error (issue a warning instead)
  -designerWarnings... issue additional warnings for protocol designers
  -compat version# ... disable new features for backward compatibility
  -allow badcase   ... enable badcases for backward compatibility
  -1990            ... all modules conform to 1990 ASN.1 syntax
  -2015            ... all modules conform to 2015 ASN.1 syntax

  -per             ... generate output file for Aligned PER encoder/decoder
  -uper            ... generate output file for Unaligned PER encoder/decoder
  -ber             .D. generate output file for BER encoder/decoder
  -der             ... generate output file for BER & DER encoder/decoder
  -xer             ... generate output file for Basic XER encoder/decoder
  -cxer            ... generate output file for Canonical XER encoder/decoder
  -cer             ... generate output file for BER & CER encoder/decoder
  -exer            ... generate output file for EXTENDED XER encoder/decoder
  -oer             ... generate output file for OER encoder/decoder
  -coer            ... generate output file for Canonical OER encoder/decoder
  -json            ... generate output file for JSON encoder/decoder

  -commandfile <file> ... read command line from 'file'
  -minimize        ... generate the smallest possible output files
  -root            ... treat all modules as root modules
  -keepnames       ... generate directives for keeping names
  -pdusforopentypes... ignore NOPDU directive for opentypes
  -nopdusforopen   ... do not generate PDUs for info objects with -noconstraints
  -shippable       ... generate .h file suitable for shipment
  -allowbadvalues  ... allow generation of bad values
  -sampleCode <pdus|values>
                   ... generate a sample code to initialize, encode, decode
                       and traverse values of PDU types defined in the input
                       ASN.1 syntax
  -noSampleCode    ... do not generate a sample code
  -relaySafe       ... retain unrecognized extension additions at runtime
  -norelaySafe     .D. do not retain unrecognized extension additions at runtime
  -maxClassesInFile num#... limits the number of classes generated into one .cpp file
  -autoencdec      ... permit automatic encoding/decoding even if -noconstraint
                       is used
  -messageFormat   <format>
                   ... display error messages in <format>:
                       'oss', 'emacs' or 'msvc'
  -xsl             ... generate default stylesheet for each PDU
  -dtd             ... generate document type definition file for each PDU
  -disablesharing	... not try to share classes in generated files
  -assignments     ... process type and value assignments defined outside
                       ASN.1 modules
  -ignoreIncompleteItems
                   ... ignore incomplete ASN.1 definitions of types and values
  -ignoreRedefinedAssignments
                   ... ignore redefined ASN.1 definitions of types and values
  -reservedWords <reserved_words>
                   ... treat words specified in the parameter and separated
                       by commas as reserved words in the generated files
                       that should be always mangled
  -inline <level>  ... inline methods of representation classes 
  -useGenericOpenTypes ... use OssOpen for table-constrained open types
  -useQualifiedNames <maxPrefixLevel>
                   ... generate context-based names for enumerators, named
                       numbers and bits
  -enablePartialDecode
                   ... generate time-optimized full and partial decoders
  -partialDecodeOnly
                   ... generate time-optimized partial decoder only

Remarks

You can obtain a synopsis of the command-line syntax by entering asn1cpp with no arguments:

OSS ASN.1/C++ Compiler Version 6.5
Copyright (C) 2017 OSS Nokalva, Inc.  All rights reserved.

asn1cpp <infile(s)> [-lean | -soed | -toed]       [-extern <name>]
  [-ber  ]          [-v    | -nov    ]            [-suppress msg#]
  [-der  ]          [-warn | -nowarn ]            [-messageFormat <format>]
  [-per  ]          [-ignoresuppress ]            [-allowbadvalues]
  [-uper ]          [-debug   | -nodebug ]        [-ignoreError msg#]
  [-json ]          [xer ] [-cxer] [-exer]        [-cer] [-oer] [-coer]
  [-root ]          [-short   | -noshort ]        [-designerWarnings]
  [-1990 | -2015]   [-unique  | -nounique]        [-gen <gendirfile>]
  [-noout  ]        [-inform  | -noinform]        [-errorfile <errorfile>]
  [-syntax ]        [-pedantic   | -nopedantic ]  [-cont <ctrlfile>]
  [-out <name> ]    [-relaySafe  | -norelaySafe]  [-commandfile <commandfile>]
  [-keepnames  ]    [-constrain  | -noconstrain]  [-h <headerfile>  | -noh ]
  [-prefix prfx]    [-mod <modlistingfile>| -nom] [-l <listingfile> | -nol ]
  [-autoencdec ]    [-test   | -notest]           [-min ]    [-pdu]
  [-maxClassesInFile num# ] [-disablesharing]     [-xsl] [-dtd]
  [-assignments]    [-encodeonly | -decodeonly  ] [-namespace <name>]
  [-restrictedConstraintChecking]                 [-compat version# ]
  [-allow badcase ] [-relaxedMode|-norelaxedMode] [-reservedWords <words>]
  [-inline level# ] [-ignoreRedefinedAssignments] [-ignoreIncompleteItems]
  [-enablePartialDecode   ] [-partialDecodeOnly ] [-shippable ]
  [-useGenericOpenTypes   ] [-useQualifiedNames   <maxPrefixLevel>      ]

enter "asn1cpp -help" for more information

Default Behavior

Command-line help is not displayed when input files are specified.

↩Options Index


-ignoreError errorNumber

Instructs the ASN.1/C++ compiler to treat certain error message numbers, specified by errorNumber, as warnings instead. Use this option to generate output files without correcting your ASN.1 specification. However, be aware that the generated values are invalid according to the ASN.1 standard.

Remarks

The current version of the ASN.1/C++ can ignore only the following message numbers: 49, 76, 77, 305, 319, 811, 832, 1078, 1130, 1162, 1207, and 1211.

Default Behavior

The -ignoreError option is turned off.

See Also

↩Options Index


-ignoreIncompleteItems

Instructs the ASN.1 Compiler to treat certain errors related to undefined ASN.1 types and values as warnings, and to ignore incomplete ASN.1 definitions that directly or indirectly reference undefined ASN.1 types or values.

Remarks

When undefined and incomplete ASN.1 items are unused by the application, use this option to generate a header file and a .cpp file without correcting your ASN.1 specification. The compiler will not consider the ASN.1 types that are referenced only by ignored incomplete types as PDUs, unless the global or local PDU directive is applied.

Use the -verbose option along with -ignoreIncompleteItems to see the incomplete items that the compiler ignored.

Example

M DEFINITIONS ::= BEGIN
   A ::= SEQUENCE {
      a1 A1,
      a2 A2,
      b B1
   }
   A1 ::= INTEGER
   A2 ::= BOOLEAN
   B ::= REAL
END

In the example above, type reference A references type B1, which is undefined.

ASN.1 compiling without -ignoreIncompleteItems results in these errors:

"test.asn", line 7 (M): A0256W: 'B1' is referenced, but is not defined.
"test.asn", line 7 (M): A0052E: 'B1' is not defined.
C0043I: 1 error message, 1 warning message and 0 informatory messages issued.

ASN.1 compiling with -ignoreIncompleteItems and -verbose:

"test.asn", line 7 (M): A0256W: 'B1' is referenced, but is not defined.
"test.asn", line 4 (M): C1215W: The definition of the type identified by the absolute reference
'M.A' is incomplete and will be ignored.

C0285I: Global checking abstract syntax.
C0286I: Generating header file.
C0287I: Generating control file.
C0043I: 0 error messages, 2 warning messages and 5 informatory messages issued.

The generated header file includes:

/* Representation types */

typedef OSS_INT32 A1;

typedef ossBoolean A2;

typedef double B;

/* Specific PDU classes */

class OSS_PUBLIC B_PDU : public ConcretePDU {
public:
    B_PDU();
    void set_data(B &);
    B *get_data() const;
protected:
    OssTypeIndex get_index() const;
};

Only one concrete PDU class is generated for type B that is not referenced by any other type in the input ASN.1 specification. Types A1 and A2 are referenced in the ignored, incomplete type A.

Default Behavior

The -ignoreIncompleteItems option is implied by the default -relaxedMode option.

See Also

↩Options Index


-ignoreRedefinedAssignments

Instructs the ASN.1 Compiler to treat some errors caused by incorrectly redefined ASN.1 types and values as warnings, and to ignore all duplicate definitions within the same ASN.1 module.

Example

M DEFINITIONS ::= BEGIN
Type ::= INTEGER
Type ::= INTEGER
END

In the example above, Type is defined twice in the same ASN.1 module, which is normally invalid ASN.1.

ASN.1 compiling without -ignoreRedefinedAssignments results in these errors:

"test.asn", line 3 (M): A0146E: Type 'Type' is illegally redefined.
Type ::= INTEGER
         ^

C0043I: 1 error message, 0 warning messages and 0 informatory messages issued.

ASN.1 compiling with -ignoreRedefinedAssignments:

"sample.asn", line 3 (M): A1270W: 'Type' has already been defined on line 2. Its
 redefinition is being ignored.

C0043I: 0 error messages, 1 warning message and 0 informatory messages issued.

Default Behavior

The -ignoreRedefinedAssignments option is implied by the default -relaxedMode option.

See Also

↩Options Index


-ignoreSuppress

Instructs the compiler to ignore any OSS.SUPPRESS directives within an ASN.1 module definition.

Default Behavior

All messages identified by the OSS.SUPPRESS directive are suppressed.

↩Options Index


-informatoryMessages | -noInformatoryMessages

Specifies whether the compiler should generate informatory messages.

Remarks

When either -relaxedMode or -noWarningMessages is specified, the -noInformatoryMessages option is implied.

When either -norelaxedMode or -warningMessages is specified, the -informatoryMessages option is implied.

The order in which -informatoryMessages | -noInformatoryMessages, -warningMessages | -noWarningMessages, and -relaxedMode | -norelaxedMode appear on the command line is important. The rightmost option takes precedence.

Default Behavior

The -noInformatoryMessages option is implied via the default -relaxedMode option.

See Also

↩Options Index


-inline level

Instructs the compiler to create definitions of some generated class methods inline with the matching class definition in the header file, rather than putting the methods in the generated .cpp file.

The operand specifies which methods will be generated inline:

  • -inline 0 : The compiler will not generate methods inline (default behavior).
  • -inline 1 : Methods consisting of exactly one C++ statement are generated inline.
  • -inline 2 : Short methods, consisting of a few C++ statements, are generated inline.
  • -inline 3 : All generated methods, regardless of length, are generated inline.

Remarks

Virtual methods are never generated inline. Also, a recursive definition of an ASN.1 type could prevent the compiler from inlining the methods of the matching C++ class.

Default Behavior

The –inline 0 option (no inlining) is implied.

↩Options Index


-keepNames

Creates a .gen file that prevents changes to the generated .h file if the input changes.

Remarks

If your ASN.1 specification or ASN.1 Compiler version changes, the ASN.1 Compiler could generate different names for the same type, requiring changes to your code. The -keepNames option instructs the ASN.1 Compiler to generate a directive for each input directive and for each name that could change if the input changes. These directives are stored in a .gen file. When the ASN.1 file needs to be recompiled, the .gen file is passed as the first input file on the command line, followed by the files and command-line options previously specified. Even when the input contains explicit identifier changes, the compiler will generate the same names as before.

When -keepNames is specified without -genDirectives, the compiler treats the input as if -genDirectives (specified without the optional genDirFilename) is also present. The name of the .gen file is obtained by changing the suffix of the last input file to .gen, unless -output is specified. This .gen file includes all directives from the ASN.1 input stream and directives for each name that could change in a subsequent run of the ASN.1 Compiler.

Example

Module DEFINITIONS ::= BEGIN
   Type ::= INTEGER {one(1), two(2), five(5)}
   S ::= SEQUENCE   {flagColor ENUMERATED {red, white, blue}}
END

When -keepNames is specified, the compiler generates the following code in the .gen file :

-- Directives artificially generated by the compiler:

--<OSS.TYPENAME Module.S.flagColor "_enum1">--
--<OSS.ExtractType Module.S.flagColor>--


-- Directives artificially generated for the names to be kept:

--<OSS.TYPENAME Module.Type "Type">--
--<ASN1.Nickname Module.Type.one one>--
--<ASN1.Nickname Module.Type.two two>--
--<ASN1.Nickname Module.Type.five five>--
--<OSS.TYPENAME Module.S "S">--
--<ASN1.Nickname Module.S.flagColor.red red>--
--<ASN1.Nickname Module.S.flagColor.white white>--
--<ASN1.Nickname Module.S.flagColor.blue blue>--

Default Behavior

The -keepNames option is turned off.

See Also

↩Options Index


-lean

Instructs the ASN.1 Compiler to generate universal output files compatible with the Space-Optimized Encoder/Decoder (SOED) and the Lean Encoder/Decoder (LED).

Remarks

Use the -lean option to restore the default behavior of the ASN.1 Compiler prior to version 5.0.

NOTE: The LED library is not included in the OSS ASN.1 Tools; it is an add-on product available for common platforms like Linux, Windows, and Solaris, and may not be available for your embedded system port. If you are interested in LED for your platform, contact OSS Nokalva Sales.

Default Behavior

The -lean option is turned off.

See Also

↩Options Index


-listingFile [listingFileName] | -noListingFile

Specifies whether the compiler should generate an ASN.1 composite listing of the root module(s), with all macro instances and parameterized items expanded, and all external references resolved.

Remarks

The optional listingFileName operand explicitly names the output listing file. If absent and -output is not used, then the filename is the same as the last input filename on the command line, with a .lst extension.

If no error conditions are detected in the input, the listing file contains valid ASN.1 that can be used as input for any ASN.1 Compiler.

Default Behavior

The -noListingFile option is implied.

↩Options Index


-maxClassesInFile <num#>

Informs the ASN.1/C++ compiler that no more than num# class definitions can be generated in one source file. When this number is exceeded, the ASN.1/C++ compiler will generate another C++ file using the same base name with a sequential suffix added. For example, when processing a file named input.asn, the generated files will be named input.cpp, input1.cpp, input2.cpp, etc.

Remarks

When the input ASN.1 specification is very large, it is impractical to generate all the C++ code into one .cpp file. Too much time and/or memory is required. Also, some C++ implementations limit the size of the input C++ source file and will reject files that are too large. Use the –maxClassesInFile option to avoid these issues.

Currently, only class methods are distributed into multiple files. The control table or generated TOED code is placed entirely in the last file. Since the TOED code can be huge by itself, it makes no sense to specify -maxClassesInFile with –toed.

Default Behavior

The compiler generates all output into a single file.

↩Options Index


-messageFormat formatScheme

Sets the format of the error, warning, and informatory messages issued by the ASN.1 Compiler. A mandatory parameter specifies which format scheme is used.

Remarks

Three format schemes are available:

oss
The default message format used by the ASN.1 Compiler:
"filename.asn", line [(moduleName)]: code: message
Example
"msgfmt.asn", line 7 (Module-10): A0217W: The identifier 'address' is missing from the value
 and is assumed.
   mySeq Seq ::= {int  5, bool TRUE, "350 5th Avenue"}
                                     ^
emacs
This format is compatible with many text editors:
filename.asn:[moduleName:]line:[position:] code: message
Example
msgfmt.asn:Module-10:7:38: A0217W: The identifier 'address' is missing from the value and 
is assumed.
msvc
This format is compatible with Microsoft development tools:.
filename.asn(line[,position]) : [moduleName:] type code: message.
Example
msgfmt.asn(7,38) : Module-10: warning A0217W: The identifier 'address' is missing from the 
  value and is assumed.

Use the format schemes with a parser or compatible text editor to help automatically find the location in the input file where the message was issued.

↩Options Index


-minimize

Automatically selects command-line options that result in a more compact control table.

Remarks

These options are automatically selected when -minimize is specified:

Default Behavior

The -minimize option is turned off.

↩Options Index


-modListingFile [listingFilename] | -noModListingFile

Instructs the compiler to generate a module listing file that contains information from multiple ASN.1 modules.

Remarks

The optional listingFileName operand explicitly names the output listing file. If absent and -output is not used, then the filename is the same as the last input filename on the command line, with a .lst extension.

Macro definitions and INSTANCE OF uses are expanded in the module-listing file, but parameterized items are not.

This option is mostly used when diagnosing compiler issues.

The module-listing file could contain invalid ASN.1.

Default Behavior

The -noModListingFile option is implied.

See Also

↩Options Index


-namespace [namespacename]

Instructs the compiler to place all generated code (classes, constants, and functions) into a C++ namespace with the specified name, which is a C++ identifier that the compiler uses as is, without validation. So, if this name is a reserved C++ word, conflicts with an ASN.1/C++ API class name, or is invalid in some other way, then the ASN.1/C++ compiler produces non-compilable C++ code.

Default Behavior

The compiler puts all output into the global (unnamed) namespace.

↩Options Index


-output [outputFilename | outputDirectoryName] | -noOutput

Specifies whether output files should be generated.

Remarks

The optional outputDirectoryName parameter specifies the directory where output files are generated. The optional outputFileName parameter specifies the prefix of the output filenames. When neither parameter is specified, the prefix of the last .asn input file is used for the output filenames. However, when these parameters are specified, the last node after the last slash is used as the prefix for the output files. So, for example, if xyz/abc is the parameter, then the output filename prefix is abc. If xyz/abc/ is the parameter, then there is no output filename prefix because the node after the last slash is empty; the files are named only with extensions such as .cpp and .h.

The -noOutput option instructs the compiler to suppress all output other than error messages.

Examples

asn1cpp foo.asn -output abc

If the abc/ subdirectory already exists under the current working directory, the ASN.1 Compiler places the foo.h and foo.cpp output files there. Otherwise, the ASN.1 Compiler generates the abc.h and abc.cpp output files in the current working directory.

asn1cpp foo -output xyz/abc

If the xyz/ subdirectory does not exist, the ASN.1 Compiler will try to create it. If successful, the compiler generates the abc.h and abc.cpp files into this subdirectory.

Default Behavior

The -output option is implied with no parameters.

↩Options Index


-partialDecodeOnly

Instructs the compiler to replace standard decoding with partial decoding. No standard encoding or decoding functions are generated, and constraint checking is disabled (-noConstraints).

Remarks

Partial decoding is supported only by the TOED runtime. That is, -partialDecodeOnly cannot be used together with the -soed option.

When -partialDecodeOnly is specified, the <module_name>_Callback class is incorporated into the generated header and code files; other definitions are unaffected.

When -xer, -exer, or -cxer is specified, the ASN.1/C++ Compiler ignores -partialDecodeOnly.

XER, CXER, E-XER, and JSON do not support partial decoding and cannot be used with the -partialDecodeOnly option.

Default Behavior

The -partialDecodeOnly option is turned off.

See Also

↩Options Index


-pdusForOpenTypes

Instructs the compiler to treat open types created by the ASN1.DeferDecoding or the OSS.ENCODABLE directive as PDUs, even when the OSS.NOPDU directive is specified.

Remarks

This option also causes open types created by the use of component relation constraints to be treated as PDUs, even when the OSS.NOPDU directive is specified.

Definition: A protocol data unit (PDU) is any simple or complex data structure that can hold a message for transfer. PDUs can be encoded or decoded as complete units. If a type is a PDU, a handler class is generated for it.

Default Behavior

The -pdusForOpenTypes option is turned off.

↩Options Index


-pedantic

Instructs the ASN.1 Compiler to thoroughly check the input file syntax.

Remarks

-pedantic implies the -syntaxOnly option; no .h or .cpp files are generated.

Default Behavior

The -pedantic option is turned off.

↩Options Index


-prefix prefix

Specifies one or more characters to prefix all generated names whose scope is global in your C++ program file.

Remarks

The -prefix option is useful when an application program supports multiple abstract syntaxes and the same typedef, class, or manifest constant name is used in the generated files. By adding a prefix to generated names whose scope is global, the output files can be C++ compiled without a multiple declaration error.

Default Behavior

Names are not prefixed.

↩Options Index


-relaxedMode | -norelaxedMode

Automatically selects command-line options that result in relaxed or strict compiler behavior.

Remarks

When -relaxedMode is specified, these options are automatically enabled:

Some significant warning messages are not suppressed when -relaxedMode is used. Use the -noWarningMessages option to suppress all warnings.

-norelaxedMode cancels the options enabled by -relaxedMode and implies the -warningMessages option.

To enable warning or informatory messages when -relaxedMode is specified, specify -warningMessages or -informatoryMessages after -relaxedMode on the command line.

To disable warning or informatory messages when -norelaxedMode is specified, specify -noWarningMessages or -noInformatoryMessages after -norelaxedMode on the command line.

Default Behavior

The -relaxedMode option is turned on.

↩Options Index


-relaySafe | -noRelaySafe

Specifies relay-safe decoding and re-encoding of messages with extension addition fields.

Remarks

When –relaySafe is not enabled and the decoder finds an extensible type containing unrecognizable extension addition fields, the decoder ignores them and returns only those fields defined in the control table. The –relaySafe option preserves these unrecognized extension additions for later re-encoding, which is especially useful for H.323-compliant firewalls, routers, packet sniffers, and similar applications.

For example, if a firewall that supports H.323 version 1 receives an H.323 version 2 message with fields that are undefined in version 1, the decoder skips those fields and returns only the version 1 fields to the firewall application. When the firewall decodes and re-encodes the message with a new IP address, the message is re-encoded as a version 1 message because the version 2 fields were skipped during decoding. With relay-safe decoding and encoding, the decoder retains the version 2 fields in the message and the encoder then re-inserts them when the firewall re-encodes the message. The result is a version-2-compliant message with the new IP address, even though the firewall understands only version 1 messages and does not know the content of the version 2 fields.

The relay-safe encoder/decoder behavior is enabled only when the ASN.1/C++ –relaySafe compiler option is specified. If not previously specified, then recompile any source files that reference the ASN.1 Compiler-generated header file with the -relaySafe option. With recompilation, the compiler generates extra methods for every extensible SEQUENCE/SET/CHOICE in the source specification. These methods provide limited access to the unknown extensions in undecoded form, if needed.

Default Behavior

The -relaySafe option is turned off.

↩Options Index


-reservedWords keyword [, keyword...]

Instructs the compiler to handle one or more comma-separated keywords as reserved words.

Remarks

By default, the ASN.1 Compiler applies a disambiguation algorithm to ensure that generated names do not conflict with words that are reserved on most popular platforms, such as the C/C++ compiler keywords double, default, const, and so on. When a conflict is detected, the compiler changes the generated names to resolve it. This process of name disambiguation is called "name mangling". The names are mangled with a prefix derived either from the ASN.1 module where the corresponding ASN.1 item is defined or, if the conflicting name belongs to a component inside another component, from the name of that outer component.

On some platforms, C/C++ compilers have keywords that are not included in the ASN.1 Compiler's default keyword list. Use the -reservedWords option to tell the ASN.1 Compiler to treat these keywords as reserved words.

NOTE: If a user-defined type name is assigned using the Nickname, TYPENAME, or FIELDNAME OSS-specific directives, and it matches the word specified in the -reservedWords option, the directive takes precedence. User-defined type names cannot be changed.

Example

Enum ::= ENUMERATED {send, bind}

ASN.1 compiling the Enum type defined above without using the -reservedWords option generates the following code:

enum Enum {
    send = 0,
    bind = 1
};

C/C++ compiling would fail because bind and send are reserved keywords for the Microsoft C/C++ Optimizing Compiler.

ASN.1 compiling with -reservedWords send, bind added to the ASN.1 Compiler command line generates code with non-conflicting names:

enum Enum {
    Enum_send = 0,
    Enum_bind = 1
};

Default Behavior

The -reservedWords option is turned off.

↩Options Index


-restrictedConstraintChecking

Instructs the compiler not to ignore the OSS.NoConstrain directive when the explicit -constraints option is present.

Remarks

When you use -constraints with -restrictedConstraintChecking, the ASN.1 Compiler enables runtime constraint checking for all types except those that have the OSS.NoConstrain directive applied.

NOTE: The -restrictedConstraintChecking option has no effect unless the -constraints option is explicitly specified.

See Also

↩Options Index


-root

Instructs the ASN.1 Compiler to treat all input modules as root modules.

Remarks

When you use the -root option, all modules are thoroughly checked, and all unreferenced types in all modules are considered PDUs.

A protocol data unit (PDU) is a message for transfer that contains data defined by an ASN.1 type. PDUs can be encoded/decoded as separate units. For each PDU, the OSS ASN.1 Compiler #defines an identification tag in the header file.

Default Behavior

By default, only the last module specified on the command line is treated as a root module.

See Also

↩Options Index


-sampleCode [pdus | values] | -noSampleCode

Instructs the compiler to generate sample code that shows how to use the generated C++ representations of PDU types defined in the input ASN.1 syntax, to call the encoder and decoder, and to traverse and print the decoded value.

The -noSampleCode option instructs the compiler to suppress sample code generation invoked by the OSS.SampleCode directive in the ASN.1 input file.

Remarks

The ASN.1 input file can define both PDU types and PDU values. To generate sample code, use the following parameters:

no parameters
Generates sample code for both types and values.
pdus
Generates sample code only for PDU types.
values
Generates sample code only for PDU values.

The sample code is created in the samplecode/ directory, which is found in the same location as the generated .h and .cpp files. The sample code is separated into the following six files, where outputname is the prefix of the generated .h and .cpp files:

  • outputname-createvalue.cpp contains function implementations that show how to initialize C++ representation of values specified by the –sampleCode option.
  • outputname-createvalue.h contains function declarations defined in outputname-createvalue.cpp for values defined with a PDU type.
  • outputname-printvalue.cpp contains function implementations that show how to traverse and print the C++ representation of PDU types from the ASN.1 input.
  • outputname-printvalue.h contains function declarations defined in outputname-printvalue.cpp.
  • outputname-testmain.cpp provides an application entry point (a main() routine) containing test code for each PDU value from outputname-createvalue.cpp. The test code calls the functions defined in outputname-createvalue.cpp to create C++ representations of the corresponding values, the OSS ASN.1/C++ Runtime API to encode and decode these values, and the functions defined in outputname-printvalue.cpp to traverse and print the decoded values.
  • makefile shows how to build an executable from all the generated files.

To customize sample values (CHOICE, SEQUENCE OF, and SET OF) you can use -sampleCode with the OSS.SampleCode directive.

To use -sampleCode, the input ASN.1 file must contain PDUs (or values). Also, make sure the the following options are not selected:

Note that a type is considered a PDU if it is not referenced by any other types, it is not imported, and it is not used in information object sets or as a type in the ContentsConstraint.

See Also

↩Options Index


-shippable

Instructs the ASN.1 Compiler to generate a special version of a header file (.h) suitable for distribution in a toolkit.

Remarks

If you purchased a Toolkit Builder License, your software distribution includes the ossship.h file that you can distribute to your customers, along with .h files generated with the -shippable option.

When you specify the -shippable option, the .cpp file is not generated. The generated .h file will #include the shippable ossship.h file instead of the OSS Nokalva internal header files, such as asn1.h, asn1mem.h, etc. This allows your customers to compile their code without unresolved symbol errors.

NOTE: Even with a Toolkit Builder License, you cannot ship any generated .cpp files or OSS Nokalva internal header files to your customers.

When you specify the -shippable option, the .h file produced can be used only for distribution to your customers.

For information about the ossship.h header file, contact Sales <info@oss.com>.

↩Options Index


-shortenNames | -noShortenNames

Specifies whether long variable names should be shortened by the ASN.1 Compiler. This option accommodates the maximum name length requirements that exist in certain C++ compilers.

Default Behavior

By default, the -noShortenNames option is implied on most platforms.

See Also

↩Options Index


-soed

Instructs the ASN.1 Compiler to generate output files for use with the Space-Optimized Encoder/Decoder (SOED).

Default Behavior

By default, -soed is disabled.

See Also

↩Options Index


-suppress messageNumber

Instructs the compiler to suppress a specific warning or informatory message.

Remarks

You can specify -suppress more than once on the command line.

messageNumber can be either the complete message identifier, such as A0210W, or only the numeric portion, such as 210.

↩Options Index


-syntaxOnly

Instructs the ASN.1 Compiler to perform only a syntax check on the ASN.1 input. This is useful when you do not need to generate a header or C++ file when debugging an abstract syntax.

See Also

↩Options Index


-test

This option is deprecated.

See Also

↩Options Index


-toed | -noToed

Instructs the ASN.1 Compiler to generate output files for use with the Time-Optimized Encoder/Decoder (TOED).

Remarks

The -noToed option instructs the compiler to not generate Time-Optimized Encoder/Decoder code.

Default Behavior

By default, the -toed option is implied.

See Also

↩Options Index


-uniquePDU | -noUniquePDU

The -uniquePDU option specifies that the tags for all PDUs must be unique, while -noUniquePDU informs the compiler that PDUs can have identical tags.

Remarks

When the -uniquePDU option is specified and the compiler encounters a duplicate PDU tag, it generates an error message. If -noUniquePDU is enabled, no error or warning message is generated. When neither option is specified, the compiler issues only warning messages.

When the –noUniquePDU option is specified, the OSS ASN.1/C++ compiler does not generate tag-controlled decoder information into the control table. Thus, tag-controlled BER decoding (using encoded tag data to derive the unknown type of a PDU) is not possible. Also, use the Time- or Space- Optimized Encoder/Decoder for tag-controlled BER decoding, as the Lean Encoder/Decoder does not support it.

NOTE: In some ASN.1 specifications, such as the Presentation Layer Protocol (ISO/IEC 8823/ITU-T X.226), PDUs do not have unique tags. In other ASN.1 specifications, such as the Association Control Service Element (ACSE), PDU tags are unique.

Default Behavior

The ASN.1/C++ Compiler issues a warning message when it detects duplicate PDU tags.

↩Options Index


-useGenericOpenTypes

Instructs the ASN.1 Compiler to generate the OssOpen class wherever an open type occurs in the input specification. This mode is compatible with ASN.1/C++ Compiler versions before 6.0.

Default Behavior

Representation of open types with table constraints changed with version 6.0 of the ASN.1/C++ Compiler. See Effect of Table Constraints on Open Types for details.

↩Options Index


-useQualifiedNames

Instructs the ASN.1 Compiler to add a prefix to:

  • Enumerators generated for ENUMERATED types.
  • Constants generated for named numbers of INTEGER types.
  • Constants generated for named bits of BIT STRING types.

For nested unnamed types, these qualified names also contain field names that could result in long identifiers. Use the optional maxPrefixLevel operand to shorten such names by limiting the number of nested fields.

Remarks

This option does not change any user-defined names assigned using the ASN1.Nickname directive.

Example

T ::= SEQUENCE {
    outerField SEQUENCE {
      innerField  ENUMERATED {en1, en2, en3}
    }
}

The ENUMERATED type in the ASN.1 syntax above is represented by the following C++ enum when compiled without -useQualifiedNames:

enum _enum1 {
    en1 = 0,
    en2 = 1,
    en3 = 2
};

Compiled with -useQualifiedNames produces the following representation:

enum _enum1 {
    T_outerField_innerField_en1 = 0,
    T_outerField_innerField_en2 = 1,
    T_outerField_innerField_en3 = 2
};

Specifying -useQualifiedNames 1 results in the following:

enum _enum1 {
    innerField_en1 = 0,
    innerField_en2 = 1,
    innerField_en3 = 2
};

Default Behavior

The -useQualifiedNames option is disabled.

↩Options Index


-verbose | -noVerbose

Specifies whether ASN.1 Compiler status messages should be issued.

Remarks

-verbose instructs the ASN.1 Compiler to issue status messages.

-noVerbose instructs the ASN.1 Compiler to suppress status messages.

Default Behavior

The -noVerbose option is enabled.

↩Options Index


-warningMessages | -noWarningMessages

Specifies whether compiler warning and informatory messages should be generated.

Remarks

-warningMessages implies the -informatoryMessages option; -noWarningMessages implies the -noInformatoryMessages option.

When -norelaxedMode is used, the -warningMessages option is implied.

The order in which the -warningMessages/-noWarningMessages and -relaxedMode/-norelaxedMode options appear on the command line is important. The rightmost option takes precedence.

Default Behavior

The -noWarningMessages option is implied by the default -relaxedMode option. However, some significant warning messages are not suppressed in the default mode. To suppress all warnings, specify the -noWarningMessages option.

See Also

↩Options Index


-xsl

Allows you to generate multiple default stylesheet files, one for each PDU.

Remarks

Normally, separate stylesheets are not produced, even when the XER encoding rules are requested. Instead, you can use your own XML stylesheets or customize those previously generated.

Every stylesheet produced has an .xsl file extension and a filename prefix matching the generated name of its corresponding PDU. You can specify a different filename prefix and extension using the OSS.Stylesheet directive.

To have the encode() method generate a reference for your stylesheet when producing XML output for a PDU, call the setXmlStylesheet() method of the OssControl class before invoking the encoder.

Examples

Using the -output or -prefix compiler options or the ASN1.Nickname compiler directive will affect the name of the .xsl file.

When the following ASN.1 syntax, input.asn, is compiled with the –xsl option, the ASN.1 Compiler is instructed to generate the Foo.xsl file. Adding the --<ASN1.Nickname Module.Foo "Bar">-- directive to the input ASN.1 causes the filename to be Bar.xsl instead.

Module DEFINITIONS ::= BEGIN
      Foo ::= INTEGER
END

The -xsl option will process a directory prefix provided by the -output option:

asn1cpp input.asn -xsl -out mydirectory/filename

The compiler will produce .xsl files into the mydirectory directory. However, the .xsl filenames will not be prefixed with the filename parameter: they will match the PDU names.

The -prefix option in combination with the –xsl option affects .xsl files by prefixing their names:

asn1cpp input.asn –xsl -prefix bar

The compiler will produce the barFoo.xsl file.

Default Behavior

The ASN.1 Compiler does not generate XML stylesheets.

See Also

↩Options Index


This documentation applies to release 6.5 and later of the OSS® ASN.1 Tools for C++.

Copyright © 2017 OSS Nokalva, Inc. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means electronic, mechanical, photocopying, recording or otherwise, without the prior permission of OSS Nokalva, Inc.
Every distributed copy of the OSS® ASN.1 Tools for C++ is associated with a specific license and related unique license number. That license determines, among other things, what functions of the OSS ASN.1 Tools for C++ are available to you.