I've been told this, and couldn't find a confirmation or rebuttal on the web. Is this true? If so, which is the limit? Is it usually enforced by compilers?
-
5I would expect this to be wildly architecture and OS dependent, and not at all something ANSI would care or concern itself with. โ Joe Jul 26 '11 at 19:54
-
@Joe: so would I, but I would expect the same about, say the [number of extern variables](http://stackoverflow.com/questions/6835718/does-ansi-c-place-a-limit-on-the-number-of-external-variables-in-a-program), or the position of the first different character in a different variable name. In both cases, ansi specifies lower bounds for what a compliant compiler must support (respectively, 4095 and either 31 or 32). Since ANSI cares about these two, it seemed plausible that it could also care about program size. โ Emilio M Bumachar Jul 28 '11 at 13:17
2 Answers
ANSI C doesn't concern itself with that kind of thing.
There is nothing in ยง5 Environment in the C99 standard that even talks about "loading a program in memory".
The only considerations are what the environment must provide to be conforming with the abstract state machine that is the basis for the language/standard. That doesn't require "loading a program in memory" - code could be spooled from a deck of punch cards.
There are limits expressed on character sets, the source code size and complexity and a few other things - but those are mostly lower bounds that a conforming implementation must accept, and relate to the translation environment, not the execution environment.

- 202,337
- 40
- 393
- 406
-
1Indeed, it doesn't even define what the "size of a program" might be. Objects have sizes. Other things, such as functions and storage used for overhead for certain operations, are likely to occupy some space *somewhere*, but the language itself provides no concept of what their size might be. โ Keith Thompson Jul 27 '11 at 02:29
If your executable is too large you may suffer thrashing, but aside from implementation-specific executable formats there isn't any maximum size.

- 2,349
- 1
- 20
- 25