This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: error: size of variable is too large


Sivaprasad.pv wrote:
while compiling our application using cross compiler,following error was occurred.

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.

--
Matthew
Me: wtf?? "#warning This is temporary since Dec 2000". Seven-year "temporary" code?
Mathieu Chouinard: Sounds like the correct definition of temporary :)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]