[comp.lang.c] Recent Questions

TLIMONCE%DREW.BITNET@CUNYVM.CUNY.EDU (12/28/87)

Let's see if I can help out with some recent questions.

----------
Problems using Turbo C and an EGA monitor?  What version of Turbo C
do you have?  The advertisements for v1.5 specifically mention EGA
support for all of the EGA text modes.  What version are you using?
(Also, they now include new libraries so that MS can't use that as
a claim against Turbo C anymore)

----------
Problems with sizeof(int) reducing portability?  I have run across this
problem too.  Actually, this is not a problem if you don't make it a problem.
When I'm programming with portability in mind I keep my 16-bit data in
shorts and 32-bit data in longs and reserve ints for when I am not in the mood
to think about size or speed (i.e. I use ints a lot).

If you are planning on some serious porting this method will be fine if
you develop on a machine that goes by the minimums (shorts >=16, longs >=32,
and shorts >= ints >= longs).  This counts for all of the machines I use/have
used but certainly may not be your case.  These minimums are therefore "good"
to develop with (but certainly not the only criteria).

What I have seen other people do in certain extemes when you always want
the code to use the exact bit-size and not "correct or overkill"-size values
you can do:
#if BITSIZE16_32
#define INT16     short
#define INT32     long
#endif
or something like that.  (maybe typedefs or maybe different names).
I'm really dragging this out (me?  long-winded?) so I'll assume you get the
point.

----------
Someone asked about prototype declarations.  Yes, ANSI C compilers will have to
prepare for the fact that all routines could be one of two calling methods.
Also, part of the "new" methods includes a ",..." sintax for variable number
of parameters which is exactly like the old method.
How do compilers know which is which?  Well, from what I can tell (correct
me if I'm wrong) a function is assumed to be of the old (caller does all
stack work) until it is declared as differently.  A definition can be by
the compiler seeing the actual code which includes either a new or old
style function or by it seeing a prototype.  That is why it is so
important to #include the .h file with the prototypes of the library you
are going to use.  Is this conveluted?  A bit.  Is it needed?  I think so.
Is it a sensible method?  Yes.  It allows old code to be mixed with new code
(almost) flawlessly.  It's basically what I expected.

                              Tom Limoncelli
  Drew U/Box 1060/Madison NJ 07940     Bitnet: tlimonce@drew.BITNET
  Disclaimer: These are my views, not my employer or Drew Univesity.
--------------------------------------------------------------------------