Where Do I Get A C Compiler? 
Author Message
 Where Do I Get A C Compiler?

After experiencing problems over the past few weeks, I am convinced that
the C compiler I am using simply does not provide enough memory for my
needs. Among other things: I wrote a simple program with nothing more
than a single call to malloc(). The results: when I approach 50-60,000
bytes, it returns that malloc failed. The size of my data has now grown
to a point where I do need this much memory and more.

Until now, I have been running a C compiler I downloaded for free from
the internet called, I believe, pacific c. I run it in DOS, through
the command 'pacc'. I have just found out that there are C compilers
that run through windows, not DOS. Maybe this is actually the
standard; I do not know. From comments I have heard, it is my
understanding that there are C compilers out there which provide much,
much more memory than 50-60K.

So my questions are: What compilers are you people out there using? How
did you get them? Are they free or at least inexpensive? Do you know any
links? (Note that at this point I do not need C++.)

I would be very grateful for help in this, because this problem is
greatly impeding my progress.

--
www.MainFrameForum.com - USENET Gateway



Wed, 09 Feb 2005 00:33:50 GMT  
 Where Do I Get A C Compiler?
I'm happy with (the free) LCC:
http://www.*-*-*.com/ .{*filter*}ia.edu/~lcc-win32/
It comes with a decent development environment and editor
called wedit that lets you do everything with a nice GUI.
Make sure you download and read the documentation too.
You can use it to write apps that run in windows, but I'd
start by writing console applications that run in DOS.


Wed, 09 Feb 2005 01:00:25 GMT  
 Where Do I Get A C Compiler?

Quote:

> After experiencing problems over the past few weeks, I am convinced that
> the C compiler I am using simply does not provide enough memory for my
> needs. Among other things: I wrote a simple program with nothing more
> than a single call to malloc(). The results: when I approach 50-60,000
> bytes, it returns that malloc failed. The size of my data has now grown
> to a point where I do need this much memory and more.

> Until now, I have been running a C compiler I downloaded for free from
> the internet called, I believe, pacific c. I run it in DOS, through
> the command 'pacc'. I have just found out that there are C compilers
> that run through windows, not DOS. Maybe this is actually the
> standard; I do not know. From comments I have heard, it is my
> understanding that there are C compilers out there which provide much,
> much more memory than 50-60K.

> So my questions are: What compilers are you people out there using? How
> did you get them? Are they free or at least inexpensive? Do you know any
> links? (Note that at this point I do not need C++.)

Your problem is an MS-DOS problem, not a C problem.  It is off topic for
this newsgroup, but I'll answer it anyway, snce I know the answer.

MS-DOS uses the x86 procesor's real-mode for memory mapping.  This is a
rather unique form of a segmented memory model.  Physical addresses in
real mode are 20-bits.  But the processor addresses them via a 16-bit
segment register and a 16-bit offset.  These two 16-bit values are
combined arithmetically to yield a 20-bit physical address.  Pointers in
programs may be "near", meaning they are only 16-bits wide and specify
an offset from a pre-loaded segment register, or they are "far" meaning
they are 32-bits wide and contain both a segment and an offset.

Anyway, the fact that the offset is only 16-bits wide creates problems
with objects that are larger than 64K.  You can't just increment
something in order to dereference off of such a pointer, because you may
need to change segments as well when you do this.  This special
handling, however, imposes run-time and compile-time overhead, so it is
usually something that can be optionally turned off.  Most major
DOS-based compilers therefore define different memory models.

The memory models that Microsoft has defined (and many other compilers
use) are:

        tiny - all code and data must fit in a single 64K segment.
               This is necessary for compiling to .COM files instead
               of .EXE files.
        small - maximum 64K code and 64K data
        medium - unlimited code, maximum 64K data
        compact - maximum 64K code, unlimited data, but no more than
                  64K per individual data object.
        large - unlimited code, unlimited data, but no more than 64K
                per individual data object.
        huge - unlimited code, unlimited data, no limit to data
               object sizes.

If your compiler lets you select different memory models, choose the
huge model.

If your compiler doesn't support the huge model, then you can either
find a compiler that does (I know the old Microsoft C 6.0 does), or
reorganize your code so that no single object is larger than 64K.  There
are many different ways to do this, and the proper way will depend on
your application.

The other possibility is to use a compiler that employs a 32-bit DOS
extender.  Use of such an extender will require a 386 or better
processor, but that shouldn't be a concern these days.  The extender
will throw the processor into 32-bit protected mode, where pointers are
32-bit offsets from a non-changing base segment - much like how memory
is managed on 32-bit x86 operating systems.

There are also DOS extenders that use the 286 protected mode memory
architecture.  Under this environment, you still have 16-bit offsets and
16-bit segments.  The difference is that segments and offsets are no
longer combined arithmetically into a 20 bit address.  Instead, the
segment address is an index into a table, used for looking up the
physical address of the start of the segment, and the offset is an
offset from there.  This allows you to use more than 1M of RAM, but it
does not eliminate the need for the various memory models.

-- David



Wed, 09 Feb 2005 01:38:48 GMT  
 Where Do I Get A C Compiler?


Quote:
> After experiencing problems over the past few weeks, I am convinced that
> the C compiler I am using simply does not provide enough memory for my
> needs. Among other things: I wrote a simple program with nothing more
> than a single call to malloc(). The results: when I approach 50-60,000
> bytes, it returns that malloc failed. The size of my data has now grown
> to a point where I do need this much memory and more.

You can use the free Digital Mars C compiler, from www.digitalmars.com,
which supports not only 16 bit DOS, but 32 bit DOS extended programming.
With the 32 bit DOS extender, you can malloc memory larger than 64Kb.

-Walter



Wed, 09 Feb 2005 03:44:57 GMT  
 Where Do I Get A C Compiler?
On Fri, 23 Aug 2002 17:00:25 GMT, Gordon Airport

Quote:
> I'm happy with (the free) LCC:
> http://www.*-*-*.com/ .{*filter*}ia.edu/~lcc-win32/
> It comes with a decent development environment and editor
> called wedit that lets you do everything with a nice GUI.
> Make sure you download and read the documentation too.
> You can use it to write apps that run in windows, but I'd
> start by writing console applications that run in DOS.

lcc-win32 is a Win32 compiler, as it's name implies.  It will make
win32 console applications that run in a text windows, but it does not
and has not ever made MS-DOS applications.  Neither do current
compilers from Microsoft, Borland, CodeWarrior, Intel, and so on.

Try it.  Boot your computer to true MS-DOS and try running an
executable produced with lcc-win32.

--
Jack Klein
Home: http://www.*-*-*.com/
FAQs for
comp.lang.c http://www.*-*-*.com/ ~scs/C-faq/top.html
comp.lang.c++ http://www.*-*-*.com/ ++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq



Wed, 09 Feb 2005 12:40:54 GMT  
 Where Do I Get A C Compiler?

Quote:

> So my questions are: What compilers are you people out there using? How
> did you get them? Are they free or at least inexpensive? Do you know any
> links? (Note that at this point I do not need C++.)

DJGPP, the MS-DOS port of GNU C. <http://www.delorie.com/djgpp/>.

Richard



Fri, 11 Feb 2005 18:30:54 GMT  
 Where Do I Get A C Compiler?
As others have mentioned, check to see if you compiler already supports
selecting the memory model.  You can also get latest version of the old
Borland compilers (and some of the new ones) for free!  Goto www.borland.com
and pick the developers link, and then the museum link.  Turbo C 2.01 is
fairly nice for pre-386 machines needing large/huge support, and djgpp as
mentioned in a different post is good for 386+ machines.


Quote:
> After experiencing problems over the past few weeks, I am convinced that
> the C compiler I am using simply does not provide enough memory for my
> needs. Among other things: I wrote a simple program with nothing more
> than a single call to malloc(). The results: when I approach 50-60,000
> bytes, it returns that malloc failed. The size of my data has now grown
> to a point where I do need this much memory and more.

> Until now, I have been running a C compiler I downloaded for free from
> the internet called, I believe, pacific c. I run it in DOS, through
> the command 'pacc'. I have just found out that there are C compilers
> that run through windows, not DOS. Maybe this is actually the
> standard; I do not know. From comments I have heard, it is my
> understanding that there are C compilers out there which provide much,
> much more memory than 50-60K.

> So my questions are: What compilers are you people out there using? How
> did you get them? Are they free or at least inexpensive? Do you know any
> links? (Note that at this point I do not need C++.)

> I would be very grateful for help in this, because this problem is
> greatly impeding my progress.

> --
> www.MainFrameForum.com - USENET Gateway



Fri, 11 Feb 2005 21:36:05 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Newbie: separate big .cs file into small .cs files

2. Compiler error CS 1595 - Help

3. Problems doing realloc, getting heap runtime error?

4. DAO3.60 - getting error 3260 when doing CDaoRecordset::Update

5. Just what *is* gets() doing?

6. PC Compiler Advice (About doing graphics)

7. what is this compiler doing? (resent)

8. what is this compiler doing? (resent)

9. gcc compiler: gets???

10. Getting FSF GNU GCC (C Compiler) to work

11. Calling a function by ptr, getting a compiler warning

12. Getting compiler error C4284 when using STL List.

 

 
Powered by phpBB® Forum Software