static int * array_size won't work because the data inside the pointer is modifiable and thus cannot be determined at compile-time.
If you are using C++11 I would suggest
constexpr int array_size = 42;
If you cannot use C++11 I would use:
static const int array_size = 42;
In both cases you create your buffer like this:
char buffer[array_size];
So without the asterisk.
If you cannot find out the size of the buffer at compile time (so the size is dependant on runtime-decisions) you need to use a dynamic array, preferably encapsulated into a std::vector:
std::vector<char> bufferVec(myDynamicSize); // Use any integer you want to
char *buffer = &bufferVec[0]; // Use this buffer as a standard array
// with size myDynamicSize OR use the std::vector
// directly (much cleaner)
[]must be a constant expression, therefore you cannot use modifiable types.static constexpr int const* array_size = &my_size;(wheremy_sizeis e.g. aconstexpr int) is possible, but not sure why you want to use that.std::vectorinstead of the array.