Symbian programming conventions

This section describes some of the general conventions for writing Symbian C++.

Typedefs for built-in types

Symbian C++ defines a set of fundamental types which, for compiler independence, are used instead of the built-in C++ types. They are provided as a set of typedefs. In addition to the arithmetic types, listed in C++ and Machine Architecture, there are TAny and TBool:
  • TAny* is used instead of void* to represent a pointer to an object of unspecified type. Note that void is still used to represent the 'nothing' return type.

  • TBool is used for booleans, with possible values of ETrue and EFalse. For historical reasons TBool is equivalent to int. Since C++ will interpret any non-zero value as true, direct comparisons of integer values with ETrue (which has the value 1) should not be made.

Layout and identifier names

To make Symbian code expressive and easy to read, common standards were adopted for code layout and for the naming of variables, functions, macros, and enumerations.

Assertions

Assertions are fatal errors that are not propagated but cause an immediate halt at the error location. Symbian provides the macros __ASSERT_DEBUG and __ASSERT_ALWAYS. Assertions are used to check for programming errors by forcing the program to fail at the point of the error. See Assertions and panics for further details.

Copyright note

Some of the material in this topic is based with permission on a Symbian Foundation wiki article Symbian C++ Miscellany which is part of the series The Fundamentals of Symbian C++. The version used was that available at http://developer.symbian.org/ on 3 November 2010. The content in this page is licensed under the Creative Commons Attribution-Share Alike 2.0 UK: England & Wales License (http://creativecommons.org/licenses/by-sa/2.0/uk).