Reputation: 9
I try to compile flushmem.cpp with ms visual c++ 2008, but obtain error: .\flushmem.cpp(69) : error C2057: expected constant expression at line: HANDLE processes[processCount]; and a warning: .\flushmem.cpp(63) : warning C4244: 'initializing' : conversion from 'unsigned __int64' to 'unsigned int', possible loss of data at line: unsigned processCount = (totalPageFile + approximateProcessConsumption - 1) / approximateProcessConsumption;
how to solve?
Upvotes: 0
Views: 127
Reputation: 5085
The Visual Studio 2008 compiler does not support a variable as the size of an automatic array. In the line:
HANDLE processes[processCount];
processCount is a variable and the compiler will only accept a constant. You will need a C99 compliant compiler or you need to change the above line of code to allocate the array. For instance:
HANDLE* processes = new HANDLE[processCount];
If you allocate the array you will also need to delete it when you are done with it:
delete [] processes;
Upvotes: 1