Source: https://mokxi.com/errors/invalid-types-for-array-subscript
Updated: 2026-11-16

Home / Errors
Arduino build error

# error: invalid types 'int[int]' for array subscript

Square brackets pick one item out of an array. The name in front of them is not an array, or the number inside is not a whole number.

Try the fixed sketch in Mokxi See the causes

- Build error
- 2 common causes
- Seen 487 times in failed builds on Mokxi in the 30 days to November 16, 2026.

The message

## What the Arduino IDE prints

Output window

It happens when an array is declared as a plain variable, or when an index is a float or a String.

Mokxi's compiler, clang, words it as subscripted value is not an array, pointer, or vector.

Causes

## The 2 usual causes with the fix

### 1The name is a plain variable, not an array

int total declares one number. int total[3] declares three. Add the size where the variable is made.

Broken

Fixed

Mokxi’s build tab says: Square brackets [ ] go after an array, and this is a single value.

Try this fix in Mokxi

### 2The index is a decimal number

An index counts items, so it must be a whole number. Convert it with an int.

Broken

Fixed

Mokxi’s build tab says: An array index counts boxes, so it has to be a whole number.

Try this fix in Mokxi

FAQ

## Questions and answers

### What does array subscript mean?

The number in square brackets, such as the 2 in values[2]. It says which item of the array you want.

### Why can I not index with a float?

Items are numbered 0, 1, 2 and so on, so a position like 1.5 means nothing. Convert it to an int first.

### Does indexing past the end give this error?

No. That compiles and reads memory that is not part of the array, which is worse. Keep the index below the array size.

Next

## More errors and the longer guide

- error: no matching function for call to 'digitalWrite(int)'
- error: lvalue required as left operand of assignment

The longer guide to this error All Arduino errors
