473,387 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

[MinGW] Stack limit


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
3 6218
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Andrew | last post by:
Last night I was reading about implementing my own stack. The example given pushes items on and off the stack at the start and end of each procedure (ie. in a std module). What's not so clear is...
14
by: Kevin Grigorenko | last post by:
Hello, I couldn't find an obvious answer to this in the FAQ. My basic question, is: Is there any difference in allocating on the heap versus the stack? If heap or stack implementation is not...
11
by: Dan Elliott | last post by:
Hello all, I am writing a program which needs to run as quickly as possible, but holds a lot of data in memory (around 1GB for a usual run). Is this too much memory to even consider putting...
12
by: jimjim | last post by:
Hello, 1. As the subject sugests, are the objects created in the stack guarranted to have been created? 2. How can I verify this? (e.g. for objects created in the heap A *a = new A one can...
4
by: Victor | last post by:
Hello, I've got a situation in which the number of (valid) recursive calls I make will cause stack overflow. I can use getrlimit (and setrlimit) to test (and set) my current stack size. ...
24
by: arcticool | last post by:
I had an interview today and I got destroyed :( The question was why have a stack and a heap? I could answer all the practical stuff like value types live on the stack, enums are on the stack, as...
8
by: gypsy3001 | last post by:
I inherited some code and got a segmentation fault on the following line: unsigned short localImage; It's really baffling and I can't think of what could cause this problem. The following are...
4
by: SP | last post by:
Hi, I've a Stack. Now I would use this to mantain a LIFO objects chain. My problem is that I want to limit the Stack dimension. If the Stack is full and I want to add a object, I eant to remove...
13
by: deepak | last post by:
Hi In the following function how the memory 'll be allocated. 1) Will it allocate memory for all the char's together or allocate for first char. then for int then for float and after this only...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.