473,320 Members | 2,094 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,320 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 6216
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.