Generated C++ files

In general, the generation logic for C++ is similar to the logic for C. Instead of the .c file extension, .cpp is used:

<moduleName>.cpp Common definitions and functions (for example, asn1Free_<type>) and/or global value constant definitions. This file also contains constructors, destructors and all methods for ASN1C_<Type> and ASN1T_<Type> control classes.
<moduleName>Enc.cpp C encode functions and C++ encode methods.
<moduleName>Dec.cpp C decode functions and C++ decode methods.

If additional options are used (such as –genPrint, -genCopy, etc), additional files will be generated:

Filename Description
<moduleName>Copy.cpp copy functions, generated if –genCopy is specified
<moduleName>Print.cpp print functions, generated if –genPrint is specified
<moduleName>Compare.cpp comparison functions, generated if –genCompare is specified
<moduleName>PrtToStr.cpp print-to-string functions, generated if –genPrtToStr is specified
<moduleName>PrtToStrm.cpp print-to-stream functions, generated if –genPrtToStrm is specified
<moduleName>Table.cpp table constraint functions, generated if –genTable option is specified
<moduleName>Test.cpp test functions, generated if –genTest is specified

The -maxcfiles option for C++ works very similar to how it works for C. The only differences are a few additional files are generated and the .cpp extension is used instead of .c. Additional files are generated to hold ASN1C_<Type> and ASN1T_<Type> control classes. The format of the filenames of these files is as follows:

   asn1<suffix>_<prodname>.cpp
   ASN1C_<prodname>.cpp
   ASN1T_<prodname>.cpp

where <suffix> depends on the encoding rules and function type selected (encode, decode, free, etc.) and <prodname> is the ASN.1 production name.

For the example presented previously in the C Files section, the following files would be generated for the Name production in the employee.asn file:

   asn1D_Name.cpp
   asn1E_Name.cpp
   ASN1T_Name.cpp
   ASN1C_Name.cpp

These contain the functions to decode Name and encode Name respectively. The ASN1T_Name.cpp file contains the type class methods, and the ASN1C_Name.cpp files contains the control class methods. Note that not all productions have a control class (only PDU types do for BER or PER) therefore the ASN1C_<type>.cpp file may not be generated.

Similar files would be generated for the other productions in the module as well.

Note that for C++, the code reduction effect is less than that for pure C. This is because most of the linkers cannot omit virtual methods even if they are not being used by the application. These virtual methods refer to separate C functions and these functions are being linked into the application even if they are not actually used. But, still, the size of the final application created with –maxcfiles option should be less than the size of the application created without this option.