C++ WCHAR: Cannot allocate an array of constant size 0
- by Rosarch
I'm trying to create a WCHAR:
LONG bufferSize = foo.bar() + 1;
WCHAR wszBaz[bufferSize];
The compiler issues an error:
error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2133: 'wszBaz' unknown size
What am I doing wrong?
UPDATE: I added const but it still gives the same error:
const LONG bufferSize = foo.bar() + 1;
WCHAR wszBaz[bufferSize];