03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Format Argument<br />

type<br />

Interpretation<br />

%d TInt Decimal value of 32-bit signed integer.<br />

%e TReal Real in scientific notation.<br />

%g TReal Real in general format.<br />

%x TUint 32-bit unsigned integer in hexadecimal.<br />

%s TText* String passed as the address of a NULL-terminated string of<br />

Unicode characters.<br />

%S TDesC* String passed as the address of a descriptor<br />

Beware of the difference between %s (for C strings) and %S (for descriptors). Also note that<br />

the descriptor version requires the argument to be a pointer to the descriptor.<br />

The SDK documents the format characters along with its documentation for<br />

TDes::Format(). There are many more options, including width and precision specifiers<br />

and variable argument positions.<br />

8.1.8 RDebug Class<br />

The RDebug class, defined in e32svr.h, includes a host of functions, of which the most<br />

interesting is Print(). If you're debugging under<br />

the emulator, RDebug::Print() prints to the debug output window. If you're debugging on<br />

target hardware, RDebug::Print() uses a serial port, which you can connect to a PC,<br />

using a terminal emulator to view the debug output. The port can be set using HAL::Set(),<br />

specifying EDebugPort and the port number, or if you are using the eshell text shell,<br />

using the debugport command.<br />

This kind of 'print debugging' is useful when a log of activity is handy, or when you have no<br />

access to the debugger. The trade-off is that you need a serial port spare on both your target<br />

hardware and your PC.<br />

8.2 C Standard Library<br />

STDLIB is the Symbian OS implementation of the standard C library. It delivers standard C<br />

functions, which are in general thin layers over corresponding Symbian OS functions.<br />

This means, on the one hand, that you can use almost all your favorite C APIs, from<br />

strlen() and malloc() to fopen() and quicksort(), and on the other, that you can<br />

usually guess the behavior of functions such as User::QuickSort() because they're<br />

there to support standard library functions.<br />

The Symbian OS C standard library was written to support the Java Virtual Machine (JVM)<br />

port, which uses Sun's C source code for the JVM with only minor alterations. By this<br />

measure alone, the standard library is well tested and powerful. It delivers POSIX-compliant<br />

C APIs layering over the Symbian OS user library, file server, and sockets server.<br />

One of STDLIB's design goals was to enable C-language modules to be ported from other<br />

systems – particularly those written for a POSIX-like environment and using the standard C

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!