Skip to content

Variables and types

LucasMW edited this page Dec 8, 2017 · 2 revisions

Variables and types

Headache has three base types: byte, short and int

Variables are declared like this:

byte b;
short s;
int i;

Variables with the same type can also be declared like this:

byte x,y,z;

and it is equivalent to this

byte x;
byte y;
byte z;

Variables can only be declared at the beginning of a scope and before their use:

correct:

 short f(short a) {
 short x,y;
 x = a;
 y = a+3;
 x = x+y;
 return x+1;
}

wrong:

short f(int a) {
 short x;
 x = a;
 short y;
 y = a+3;
 x = x+y;
 return x+1;
}

variables are assigned with values of their type:

short x;
byte y;
x = 257;
y = 5+y;