Page 1 of 1

Const expression expected

Posted: 16 Mar 2022 21:24
by Luyar
Hi

What am i doing wrong here :

void RGBLCD1602_command(unsigned int value)
{
unsigned int lcddata[3] = {0x80 , value};
RGBLCD1602_send( LCD_ADDRESS , lcddata , 2);
}

I get a compiler error :

Const expression expected
Too many initializers

Thanks,

Re: Const expression expected

Posted: 21 Mar 2022 18:35
by darko.ilijevski
Hello,

The problem is the following line:

Code: Select all

unsigned int lcddata[3] = {0x80 , value};
You can't initialize an array with variables. Only constants and literals. For example, this would work:

Code: Select all

const int value = 0xA0;
unsigned int lcddata[3] = {0x80 , value};