473,395 Members | 1,931 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,395 software developers and data experts.

Program size limitation

AB
Hello all,

I heard once that there is a limitation on the number of lines of code
that a program can have when using C, but not for C++. Is this true?

Any ideas?

Jul 13 '06 #1
6 2674
AB wrote:
Hello all,

I heard once that there is a limitation on the number of lines of code
that a program can have when using C, but not for C++. Is this true?
Depends on your compiler.

--
Ian Collins.
Jul 13 '06 #2
"AB" <ab*****@gmail.comwrites:
I heard once that there is a limitation on the number of lines of code
that a program can have when using C, but not for C++. Is this true?

Any ideas?
The C standard imposes no specific limit on the number of lines either
in a translation unit or in a program. A compiler could impose such a
limit, I suppose, but there's no particular reason to do so (unless
it's a cripped demo). As far as I know, it's the same for C++.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jul 13 '06 #3
AB a écrit :
Hello all,

I heard once that there is a limitation on the number of lines of code
that a program can have when using C, but not for C++. Is this true?

Any ideas?
Some compilers (like MSVC 6.0 for instance) would have problems
when compiling sources with more than 65535 lines. This is due
to the debug information format that MSVC was using some years ago.

Other compilers have no practical limits, even if the OS can have some
limitations.

Gcc under windows (mingw) stops at more than 65535 relocations in an
object module. lcc-win32 had this limit some years ago but I took it
away, maybe mingw has done that too, I do not know.

Of course there is the limitations of disk space (I think that above
1000 million lines your hard disk starts getting full) and there is some
limitations in executable size: under 32 bits systems you usually
can't have a program of more than 2GB size (2GB reserved for the
system) or at most 3GB... This surely puts a stop in the number of lines
of code your program can have. 64 bits systems do not have that
limitation but may have others, since no one has implemented a full
64 bit virtual space yet.

jacob
Jul 13 '06 #4
"jacob navia" <ja***@jacob.remcomp.frwrote in message
news:44*********************@news.orange.fr...
AB a écrit :
>I heard once that there is a limitation on the number of lines of code
that a program can have when using C, but not for C++. Is this true?

Of course there is the limitations of disk space (I think that above
1000 million lines your hard disk starts getting full) and there is some
limitations in executable size: under 32 bits systems you usually
can't have a program of more than 2GB size (2GB reserved for the
system) or at most 3GB... This surely puts a stop in the number of lines
of code your program can have.
Not true. Someone here recently posted an example of a program that had
thousands of lines of code, branches, computed gotos, functions, etc. that,
after optimization, resulted solely in the machine code equivalent of
"return 7;". It is a common beginner mistake to assume that source code
size has any relation to the output code size.

Also, even on 32-bit systems, there is no fundamental limit of 2GB or 3GB;
that's an implementation detail. There is at least one x86 Linux variant
that gives user code 4GB minus a few (4kB) pages for trapping NULL and for
switching to kernel page tables on a syscall. If that's not enough, the
implementation could implement overlays so that the actual program could
exceed 4GB, just not with all parts loaded at the same time. MS implemented
similar tricks in Windows for accessing parts of 36-bit PAE memory within
32-bit userland.

Even disk space is not a practical limitation, since one can always add more
disks to make bigger arrays and use multiple object files if a single object
would exceed a 64-bit filesystem.

The only practical limit is in how complex a program can get and still be
correct and maintainable.
64 bits systems do not have that limitation but may have others, since
no one has implemented a full 64 bit virtual space yet.
That's really no different than the 32-bit non-limits.

I am a little curious what happens when __line__ exceeds the range of a long
long, though...

S

--
Stephen Sprunk "Stupid people surround themselves with smart
CCIE #3723 people. Smart people surround themselves with
K5SSS smart people who disagree with them." --Aaron Sorkin
--
Posted via a free Usenet account from http://www.teranews.com

Jul 13 '06 #5
"Stephen Sprunk" <st*****@sprunk.orgwrites:
[...]
I am a little curious what happens when __line__ exceeds the range of
a long long, though...
(__LINE__, not __line__)

__LINE__ expands to

The presumed line number (within the current source file) of the
current source line (an integer constant).

(C99 6.10.8p1)

Presumably it could be an unsigned long long literal. I suppose an
attempt to use __LINE__ when the line number exceeds ULLONG_MAX would
invoke undefined behavior.

The "#line" directive can be used to change the presumed line number,
but:

The digit sequence shall not specify zero, nor a number greater
than 2147483647.

(C99 6.10.4p3)

That's not in a constraint, so attempting to use #line to set the
presumed line number to ULLONG_MAX would invoke undefined behavior.

I see this is cross-posted to comp.lang.c++; the C++ rules may be
different.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jul 13 '06 #6
In comp.lang.c++ jacob navia <ja***@jacob.remcomp.frwrote:
: AB a ?crit :
: Hello all,
: >
: I heard once that there is a limitation on the number of lines of code
: that a program can have when using C, but not for C++. Is this true?
: >
: Any ideas?
: >

TI suspect the 4 GByte limitation is for "flat mode" with x86 architecture,
meaning un-segmented (all code in one s32-bit segment), as then the max
offset for EIP = 2^32 - 1.

-- Scott
==========
: Some compilers (like MSVC 6.0 for instance) would have problems
: when compiling sources with more than 65535 lines. This is due
: to the debug information format that MSVC was using some years ago.

: Other compilers have no practical limits, even if the OS can have some
: limitations.

: Gcc under windows (mingw) stops at more than 65535 relocations in an
: object module. lcc-win32 had this limit some years ago but I took it
: away, maybe mingw has done that too, I do not know.

: Of course there is the limitations of disk space (I think that above
: 1000 million lines your hard disk starts getting full) and there is some
: limitations in executable size: under 32 bits systems you usually
: can't have a program of more than 2GB size (2GB reserved for the
: system) or at most 3GB... This surely puts a stop in the number of lines
: of code your program can have. 64 bits systems do not have that
: limitation but may have others, since no one has implemented a full
: 64 bit virtual space yet.

: jacob
Jan 24 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rick Brough | last post by:
I'm in the early stages of researching the migrating of an OLTP Oracle database (size 200+ GB) and still growing to PostgreSQL 8.x. Before I spend alot of time documenting the migration path, I'd...
2
by: Anurag | last post by:
This simple one beats me all ends up(sincerely). I have been doing DB2 UDB for some time now, reading a lot of good discussions in this forum, writing some answers, asking a lot more but this...
19
by: Jerry | last post by:
I am wondering what is the maximum size of memory that malloc() could handle. Is there any limitation on that? Where am I supposed to get this kind of information? Thank you everybody.
5
by: praveen | last post by:
Hello Folks; I am working in ASP.NET application. I would like to know how much characters ( OR How much Size?) I can keep in View State variable. I want the limitation in its size. Is there any...
2
by: Joseph Geretz | last post by:
I'm developing a Web Service using DIME to download and upload files from and to an IIS server. In order to increase the download filesize to unlimited, I have the following block in my App.config...
22
by: Vijay | last post by:
With the option strict On set..... Dim fs As FileStream = File.OpenRead(strFile) With fs Dim buffer(fs.Length) As Byte ' <--- Option Strict On disallows implicit conversions from 'Long' to...
6
by: AB | last post by:
Hello all, I heard once that there is a limitation on the number of lines of code that a program can have when using C, but not for C++. Is this true? Any ideas?
1
by: amiben | last post by:
Hi everyone. I have an .asp file that is included in my sites pages which holds information in a string array. The array is so large that the include file is almost 900kb in size. Some array...
4
by: leegold58 | last post by:
Hi, Is there a "way around" the size limitation for Access? I'm thinking of something like spanning a huge table accross multiple databases... Something simple and that would preserve the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.