# Basic Rules for Naming Functions and Variables

## Category

Nitro SDK functions can be classified into categories according to their application and they have been given names that help make this clear.

Category
  These consist of two or more continuous uppercase letters. (Numerals can also be used, but for graphics only.)

  > [A-Z][A-Z0-9]+

OS | Items related to the OS system.
G2,G3,GX... | Items related to graphics. (Numerals are also included.)
MI | Items related to memory exchange such as DMA.
SVC | Items related to system calls.

(03/11/13)

Note: The distinction in the main processor and subprocessor categories was eliminated and all caps are used uniformly.

(04/01/18)

## Functions

Functions are named as follows: Subject and object connected without an underscore with the first letter of each separate word capitalized.

Public functions (API)
  [Category name]_[verb] [object, etc]

  > Example: OS_SetInterruptMask, OS_IsLocked

Private functions
  [Category name]i_[verb] [object, etc]

  > Example: OSi_SetInterruptMaskBase

static functions
  freely

However, there are some functions that do not traditionally follow this rule, such as `OS_InterruptHandler`.

(03/11/13)

There are two methods available for deciding the name of a function that generates and/or initializes objects. One is `Create` and the other is `Init`. In this case, `Create` is used when a function for explicitely destroying the object must be called, while `Init` is used when disposal processing is not required.

(03/12/15)

## Variable Type Name

Functions and types are the same since the name used in typedefs fundamentally adhere to GAMECUBE conventions. Note that a verb is not used after the category name.

Variable type name
  [Category name] [noun]

  > Example: OSInterruptCallback

Variable name (exception)
  [Category name] [verb] Mode

  > Example: OSCopyMode

As an exception, names such as `OSCopyMode` given above are included for functions used to control the operations of the API itself. In this case, the function is likely to control the operations of a function having a name like `GXCopy`. Names such as `GXCopyStatus` and `GXCopyType` are also conceivable for a function like this. Although this is recognized as a natural way to name such functions, do not take this concept too far.

(03/11/13)

## Enumerator Names and Macro Names

Constants defined by `enum`, `define`, and `const` will have the format shown below.

Constant Name
  [Category name] _ [A-Z0-9_]+

  > Example: OS_INTERRUPT_MAX, OS_INTERRUPT_MAX

(04/01/18)
CONFIDENTIAL

NTR-06-0022-001-B
CONFIDENTIAL