This is the mail archive of the
mailing list for the GCC project.
Re: error: size of variable is too large
- From: Matthew Woehlke <mw_triad at users dot sourceforge dot net>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 13 Nov 2007 14:51:04 -0600
- Subject: Re: error: size of variable is too large
- References: <472AECE2.email@example.com>
while compiling our application using cross compiler,following error was
error: size of variable `a_var' is too large
where 'a_var' is structure variable(It is around 2MB of size).
I want to know Is there any limit for variable size.Is it depend on
particular target to which gcc is ported.
please help me in order to resolve this issue.
If allocated on the stack, an allocation that exceeds the stack size
will cause your program to SEGV at runtime. It may be that gcc
additionally refuses to compile code that statically allocates a "large"
amount of stack space (for some definition of "large").
It sounds like you are trying to allocate a ~2 MiB struct on the stack.
Consider using malloc() (and of course, remember to free()) instead.
Allowable stack allocation on POSIX systems is determined by the
ulimit/rlimit; default values for this vary by platform, system
configuration, and potentially even users' login profiles.
Me: wtf?? "#warning This is temporary since Dec 2000". Seven-year
Mathieu Chouinard: Sounds like the correct definition of temporary :)