By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,205 Members | 1,027 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,205 IT Pros & Developers. It's quick & easy.

[MinGW] Stack limit

P: n/a

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 ?

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~l-.~~~~~~~~~~~~~~~~~~~
GG-1175498 ____| ]____,
Rafal 'Raf256' Maj X-( * )
Rafal(at)Raf256(dot)com ,"----------"
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Rafal 'Raf256' Maj wrote:
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 :-)
--
Bertrand Mollinier Toublet
"Uno no se muere cuando debe, sino cuando puede"
-- Cor. Aureliano Buendia

Nov 13 '05 #2

P: n/a
Rafal 'Raf256' Maj wrote:

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)[b];

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 */

--
pete
Nov 13 '05 #3

P: n/a
In <Xn**********************@213.180.128.20> "Rafal 'Raf256' Maj" <sp**@raf256.com> writes:

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
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.