error initializing an array of colors. [solved]

This works:

int colorCount = 4;
CRGB colors[4] = {CRGB::Red, CRGB::Green, CRGB::Blue, CRGB::Black};

This does not:

int colorCount = 4;
CRGB colors[colorCount] = {CRGB::Red, CRGB::Green, CRGB::Blue, CRGB::Black};

The error is:

error: array bound is not an integer constant before ']' token
 CRGB colors[colorCount] = {CRGB::Red, CRGB::Green, CRGB::Blue, CRGB::Black};

---Edit---- DOH!, read the error message.

const int colorCount = 4;
CRGB colors[colorCount] = {CRGB::Red, CRGB::Green, CRGB::Blue, CRGB::Black};

Why not let the compiler do the counting for you?

CRGB colors[] = {CRGB::Red, CRGB::Green, CRGB::Blue, CRGB::Black};
const uint8_t colorCount = sizeof(colors) / sizeof(colors[0]);

Also, note use of unsigned type as it's highly unlikely the number of colors will be negative.

Declare colorCount as const int.