[MinGW] Stack limit

R

Rafal 'Raf256' Maj

Hi,
is this group good for questions also little compiler/platform related?

int tab[1024][1024];

program with this instruction compiled undre MinGW(DevCPP) and executed
under WinXP - crashes in this instruction. Probably due to stack overflow
error. How can I increase stack limit? Is there some universal method for
most C/C++ compilers ?
 
B

Bertrand Mollinier Toublet

Rafal said:
Hi,
is this group good for questions also little compiler/platform related?

int tab[1024][1024];

program with this instruction compiled undre MinGW(DevCPP) and executed
under WinXP - crashes in this instruction. Probably due to stack overflow
error. How can I increase stack limit? Is there some universal method for
most C/C++ compilers ?
One universal solution, that is also on-topic for this NG, is to respect
the maximum supported object size laid out by the C standard, which is
of 65535 (or was it 65536) bytes (with bytes to be taken in the C
meaning of 1 byte = sizeof(char)).

Admittedly, that doesn't help you too much :)
 
P

pete

Rafal said:
Hi,
is this group good for questions also little compiler/platform related?

int tab[1024][1024];

program with this instruction compiled undre MinGW(DevCPP) and executed
under WinXP - crashes in this instruction. Probably due to stack overflow
error. How can I increase stack limit? Is there some universal method for
most C/C++ compilers ?

malloc might help do something close to what you want.

/* BEGIN new.c */

#include <stdio.h>
#include <stdlib.h>

#define A 1024
#define B 1024

int main(void)
{
int (*tab);

tab = malloc(A * sizeof *tab);
if (!tab) {
fputs("It didn't work.\n", stderr);
exit(EXIT_FAILURE);
}
tab[1023][1023] = -1;
printf("%d\n", tab[1023][1023]);
free(tab);
return 0;
}

/* END new.c */
 
D

Dan Pop

is this group good for questions also little compiler/platform related?

Nope. What's wrong with using compiler/platform related newsgroups?
int tab[1024][1024];

program with this instruction compiled undre MinGW(DevCPP) and executed
under WinXP - crashes in this instruction. Probably due to stack overflow
error. How can I increase stack limit? Is there some universal method for
most C/C++ compilers ?

Nope. You can try prefixing your declaration by static, so that
the array is no longer automatically allocated. Or allocate it
dynamically, with malloc and friends.

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top