Hi,
Is there a constraint on the maximum size of the Structure that can be defined in VC++.
Thanks in Advance,
Varadha
Printable View
Hi,
Is there a constraint on the maximum size of the Structure that can be defined in VC++.
Thanks in Advance,
Varadha
When i define the following struture
typedef struct summa
{
int a;
int b;
char c[1062144];
}summa;
and run the application, i get the following error.
Unhandled Exception: ..... Stack Overflow
This is because its too big for the stack. You could allocate it with new and put it on the heap instead. Or you could increase the size of your stack in the linker options.
Or use a std::string or std::vector<char> as a structure member, which essentially puts that memory on the heap.
What problem are you trying to solve, or is the question academic?
Jeff
Thanks Dave and Jeff, as u have said the problem is size of the structure is beyond the stack size.
How can i increase the stack size?
Can u give me some online tutorial on this.
MSDN "Visual C++ Linker Options":Quote:
Originally posted by Varadha
Thanks Dave and Jeff, as u have said the problem is size of the structure is beyond the stack size.
How can i increase the stack size?
Can u give me some online tutorial on this.
That said, usually when one thinks they need to increase the stack size, it is because they are abusing the stack (char c[1062144];). Rethink your design.Quote:
The /STACK option sets the size of the stack in bytes. This option is only for use when building an .exe file.
[QUOTE]Originally posted by Andreas Masur
MSDN:Quote:
In is case I would rather say that he needs the 'Zm' option...
Hi Andreas,Quote:
/Zm (Specify Precompiled Header Memory Allocation Limit)
I'm ignorant. Can you explain how that pertains to this?
However, as the others also pointed out, you seem to be abusing the stack here, and should rather allocate that amount of memory on the heap instead of increasing the stack size. Besides that, what is the use of a structure that amount of memory as a static character array? You should rather rethink your design (or explain why you need to do this).Quote:
Originally posted by Varadha
Thanks Dave and Jeff, as u have said the problem is size of the structure is beyond the stack size.
How can i increase the stack size?
Can u give me some online tutorial on this.
No you don't...but I am stupid...forget about it, I was thinking about something different wile writing this...sorry about this...I already have deleted my nonsense...Quote:
Originally posted by vicodin451
I'm ignorant. Can you explain how that pertains to this?