LanguageUpdated 2026-07-24

GPC variables and arrays

Understand signed 16-bit runtime values, global storage, local scope, initialization, and safe array indexing.

Overview

Standard GPC variables are signed 16-bit integers. That range affects arithmetic, counters, controller values, and intermediate results.

Arrays group indexed values. Keep indexes within declared bounds and be deliberate about global versus function-local lifetime.

Key facts

  • GPC variables are signed 16-bit integers.
  • Global declarations appear before runtime blocks.
  • An array index must remain within the declared element range.
  • Overflow-sensitive arithmetic should be redesigned or checked against current compiler behavior.

GPC syntax examples

Examples are intentionally small. Replace identifiers only with values documented for your target.

State and lookup valuesexample.gpc
int enabled = FALSE;
int levels[3] = { 25, 50, 75 };

main {
    if (enabled) {
        set_val(XB1_A, levels[1]);
    }
}

Functions, commands, and terms

Names below are catalog entries, not guessed signatures. Open the official sources for current parameter and return-value details.

NameKindPurpose
intdeclaration

Declares signed 16-bit runtime variable storage.

int[]declaration

Declares indexed signed-integer storage.

Common mistakes

Assuming standard variables are 32-bit.

Using a negative or out-of-range array index.

Relying on an uninitialized value instead of assigning intentionally.

Official GPC sources

Use these first-party references to confirm exact syntax and runtime behavior for your installed firmware and Studio version.

Related GPC references