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
typedef
s.
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).
- Naming Conventions
Applications on the Symbian platform use a standard set
of conventions to name their classes, structs, variables, functions,
macros, enumerations, and constants. This topic explains the meaning
of these conventions.
- Layout conventions
Symbian code is laid out in a standard way. This information
is provided to help you to read Symbian code, even if you choose not
to adopt the same layout yourself.
- Assertions and panics
To help Symbian developers identify potential problems
early in development, macros are provided to test for error conditions
in functions (asserts) and objects (class invariants). Assertions
are implemented using panics.
- C++ and machine architecture
The C++ language, following its foundation in C, is close
to the machine architecture. This allows applications to be implemented
efficiently, but, especially for developers new to the language, presents
some issues of which you need to be aware. This topic reviews the
basic language features from this perspective, and discusses how the
resulting issues are handled.
- Code Efficiency