# HLSL: array conversion error

## Recommended Posts

Bvandeweyer    122
I'm stuggling with arrays in HLSL. Even a simple code like this:
int Array[2],
Array[1] = 2,
Array[2] = 1;

gives me the following error: "Cannot convert from int to int[ ]..." This means I can't write any value in the array, but I have no idea why this happens. Somehow an integer or float can't be converted to be put into the array. Anyone knows why it gives this error, and how to solve this ? I've been trying to solve this for the past 3 days, but without any luck (even google let me down for the first time). Any help is highly appreciated ! Thanks.

##### Share on other sites
Cypher19    768
Umm...
1) Shouldn't your lines be ending with semicolons?
2) If you have a size 2 array, the indices will be from 0 to 1, not 1 to 2.

##### Share on other sites
Bvandeweyer    122
Well, I thought that too...

but with the semicolons I receive:
"Syntax error: unexpected token '['"

and with the array range starting from 0:
"Error X3059: 'Array': array dimension must be between 1 and 65536"

So when I use the piece of code from my previous post, the syntax looks right, apart from that nasty conversion problem...

BTW, I'm using NVidia's FXComposer to write my shaders and thus get the errors there (but it doesn't work in the gameengine either though).

I think I'm going crazy... ;)

Thanks though.

##### Share on other sites
Bvandeweyer    122
Just a quick question to check if all my efforts were not in vain:

Is it possible that arrays in hlsl are read-only ?

##### Share on other sites
benryves    1999
Bear in mind that I know nothing about HLSL... but is "Array" a reserved keyword? Would it work if you changed "Array" to "my_array"?
Just a hunch. [smile] You did say any help...

##### Share on other sites
Bvandeweyer    122
@ Ben: no, "array" isn't a reserved word... but thanks for the suggestion !