(C++) Assertion failed: !"Bad error code", file VMem.c, line 715

 

(C++Assertion failed: !"Bad error code", file VMem.c, line 715

 

Misc error.

  

 myInterface

 

Full error message

 

Assertion failed: !"Bad error code", file VMem.c, line 715

 

 

 

 

 

 

Cause

 

IDE: C++ Builder 6.0

Project type: VCL

 

Appears when linking the following code:

 

#define ARRAY_SIZE 10000000

int main()
{
  int array[ARRAY_SIZE];
}

 

 

 

 

 

Solutions

 

When this error occurs, restart C++ Builder and nothing has been lost. Do change the code as in one of the examples below.

 

 

 

 

 

Decrease the value of the array size

 

#define ARRAY_SIZE 1000000

int main()
{
  int array[ARRAY_SIZE];
}

 

 

 

 

 

Create the array dynamically

 

#define ARRAY_SIZE 10000000

int main()
{
  int * const array = new int(ARRAY_SIZE);
}

 

 

 

 

 

Use a std::vector (preferred)

 

#include <vector>

int main()
{
  const int sz = 10000000;
  std::vector<int> v(sz);
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

你可能感兴趣的:(assert)