1

I use VC2010 and when i try to debug my progam with struct replacing static i get

Unhandled exception at 0x000f18e7 in ht_array.exe: 0xC00000FD: Stack overflow.

it does it at the first line of main

#define BUCKETS 64
#define B_ENTRIES 50000

void main(int argc, char **argv)
{
static fpinfo hash_table[BUCKETS][B_ENTRIES];
static tanker_record tr[100];
....
John
  • 794
  • 2
  • 18
  • 34
  • you just tried to put 3.2 MBytes at least on the stack, not a good idea, move the variable definitions outside of main. – Dampsquid Feb 28 '12 at 14:36

2 Answers2

3

Because 64 * 50000 * sizeof(fpinfo) bytes is apparently too big for your stack. With static, the variable is allocated in a different region of memory, where it does fit.

Fred Foo
  • 355,277
  • 75
  • 744
  • 836
2

Removing static means hash_table is now a stack variable whose size is too big for the stack.

static variables are stored elsewhere (see this question).

Community
  • 1
  • 1
hmjd
  • 120,187
  • 20
  • 207
  • 252