3. Implementation Tips

This chapter provides cautions and other helpful information related to developing an application.

3.1. Initialization Before Starting an Application

As explained in the CTR System Programming Guide, applications can implement their own versions of the following initialization processes that are run when an application is started.

  • nninitStartUp function definition
  • C++ static initializers
  • C static initializers

The nninitStartUp function definition initializes memory-management features, and does so before the static initializers. This function is defined by a weak symbol. Applications can override it by defining a function with the same name.

The default implementation can be found in the nninitStartUpDefault function in $CTRSDK_ROOT/sources/libraries/init/init_Default.cpp. Nintendo strongly recommends that you replace this function with your own implementation of the nninitStartup function.

3.2. Entry Function

The nnMain function is the entry (main) function of a program, and is called after initialization. This function implements the application process.

When the nnMain function exits, the application closes and control returns to the HOME Menu (or the development menu).

3.2.1. Handling Special Actions

Applications must handle the following actions.

  • HOME Button presses.
  • Transitions to Sleep Mode when the system is closed.
  • POWER Button presses.

For more information, see the 3DS Programming Manual: System.


CONFIDENTIAL