Markku Kolkka wrote:
Dotan Cohen kirjoitti viestissään (lähetysaika lauantai, 26.
marraskuuta 2005 13:16):
We're learning C in the university and we MUST compile on
Turbo C. So I need to know how different that piece of windows
software is from gcc. If I compile in gcc, can I safely bet
that the code will compile in Turbo C?
No. Turbo C is an ancient (latest version is from 1989) compiler
for 16-bit MS-DOS. It's possible that with careful coding and
trial and error you might be able to create simple programs that
compile correctly under both Turbo C and GCC.
This is incorrect. Both Turbo C and GCC are ANSI C compliant.
Any compliant program which is written to be portable can be compiled
and run on either of them.
Possible areas where one would need special attention:
(1) Weak handling in Turbo C of the underlying architecture
allowing leakage of the segment:offset format of pointers:
This is best handled by changing the compiler "model", not
by use of the "far" and "near" added keywords in Turbo C.
Stick to ANSI C and you'll be all right. Use "large" and
"huge" models when you really need far pointers.
(2) Accidentally exceeding the limits of 16 bit integers:
Many people today just automatically presume that integers
are at least 32 bits. Coding for portability means not
doing that. Use the appropriate types. And know what that means.
For small integers which need to be fast, like loop
counters etc. use "int". For integers which need to be
able to handle large numbers, use "long int". Similarly
for the unsigned versions.
(3) Actual limitations on the amount of data which can be
loaded at any one time: No single object in Turbo C can
exceed 65536 bytes in total size.
Of these, only (3) poses any real risk of having to write
specially coded algorithms.
Mike
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!