Extern Linkage

Most common compilers support applying external linkage to an entire class, but Symbian’s does not. Symbian also requires that both prototype and implementation be marked with the appropriate linkage. When the -symbian option is specified, generated code is modified to accommodate these requirements.

The following specification will demonstrate the differences between code generated with Symbian and without:

   Test DEFINITIONS ::= BEGIN
                
   A ::= NULL
                
   END

The usual class definition for this specification looks like this:

   class EXTERN ASN1C_A :
   public ASN1CType
   {
      protected:
      public:
      ASN1C_A ();
      ASN1C_A (OSRTMessageBufferIF& msgBuf);
      ASN1C_A (OSRTContext &context);
      // standard encode/decode methods (defined in ASN1CType base class):
      // int Encode ();
      // int Decode ();
                
      // stream encode/decode methods:
      int EncodeTo (OSRTMessageBufferIF& msgBuf);
      int DecodeFrom (OSRTMessageBufferIF& msgBuf);             
   } ;

It is very similar to the Symbian class definition:

   class ASN1C_A :
   public ASN1CType
   {
   protected:
   public:
      EXTERN ASN1C_A ();
      EXTERN ASN1C_A (OSRTMessageBufferIF& msgBuf);
      EXTERN ASN1C_A (OSRTContext &context);
                
      // standard encode/decode methods (defined in ASN1CType base class):
      // int Encode ();
      // int Decode ();
                
      // stream encode/decode methods:
      EXTERN int EncodeTo (OSRTMessageBufferIF& msgBuf);
      EXTERN int DecodeFrom (OSRTMessageBufferIF& msgBuf);
                
   } ;

Note the use of EXTERN in the generated code: it prefixes the constructors and the encoding and decoding functions, but not the class declaration. These prefixes are repeated in the implementation:

   EXTERN ASN1C_A::ASN1C_A () : ASN1CType()
   {
   }

Users should not have to modify generated code for use on the Symbian platform, but should be aware of these particular differences when writing Symbian applications.