Dec 182017
 
CCT is a Turbo C command line Pre-Processor. If you don't use th integrated environment this my be for you. Allows you to set compiler switches from within your source code. Source included for Turbo C.
File CCT.ZIP from The Programmer’s Corner in
Category C Source Code
CCT is a Turbo C command line Pre-Processor. If you don’t use th integrated environment this my be for you. Allows you to set compiler switches from within your source code. Source included for Turbo C.
File Name File Size Zip Size Zip Type
CCT.C 10760 3358 deflated
CCT.DOC 9910 3674 deflated
CCT.EXE 14986 9043 deflated
CCT.MSG 600 387 deflated

Download File CCT.ZIP Here

Contents of the CCT.DOC file




CCT.EXE

A TCC Command Line Pre-processor

Copyright (c) 1990 by Keith Ledbetter
-------------------------------------



Introduction
------------

If you use the Turbo C command-line compiler (TCC) quite a bit, or if you
use an editor other than Turbo C's built-in TC editor (ie: Multi-Edit, Brief),
then CCT will be a very handy utility for you to have.

CCT is a pre-processor for the Turbo C command-line compiler (TCC) that
allows you to set compiler switches with directives IN YOUR SOURCE CODE, much
like Turbo Pascal's {$R, $S, etc} switches. There are many advantages to this
type of processing; my main problem is that almost all of my different programs
depend on different compiler settings. With CCT, you'll never again have to
try to remember if you had, for example, "jump optimization" on when you first
developed this code -- you will have it documented IN your source code for
future reference.

Of course, the big advantage to CCT is that you don't have to try to
remember all of those obscure command line switches, or have tons of different
batch files on your hard drive to do different types of compiles. CCT will
handle everything for you.

The main reason that I wrote CCT was because I have switched to using
Multi-Edit instead of Turbo C's built-in editor. Multi-Edit is a very nice
editor, and has hooks to call TCC directly when you press the "compile" key
(in fact, it will even parse down the error message file just like Turbo C's
integrated environment does, placing the cursor on the next error).

Unfortunately, when using a different editor, you don't have access to
Turbo C's integrated drop-down configuration windows for setting things like
register optimization, memory model, etc. And, I got tired of constantly
having to change the command line configuration that Multi-Edit passes to the
TCC compiler. Now, with CCT, you simply place your switch configurations in
your source code, and have your editor call CCT instead of TCC.



How it works
------------

To invoke CCT, you simply execute the following command format:

CCT hello.c

where "hello.c" is replaced by the name of the C source you wish to compile
(the ".c" is appended onto the file name if you don't specify it).

CCT will read up to the first 100 lines (this can be changed by modifying
the #define MAX_DEPTH to any number you want) of "hello.c" looking for lines
that begin with "#cct" in column one. For each line that it finds beginning
with "#cct", it will parse down the line looking for compiler switches that
you would like to set. There can be a multiple number of switches specified
on each "#cct" line.

So, all you need to do is to put a comment block somewhere near the top of
your code that specifies your specific requests for that program. Here is an
example piece of code:

------------------------------------------------------------------------------

/* The ever-popular "Hello, world" program */

/*
Compiler switches for the CCT pre-processor
-------------------------------------------

#cct Model: Small, Output: Hello.Exe, Code_type: 8086
#cct Include: D:\tc\include, Lib: D:\tc\lib
#cct Ansi: Yes, Align: Byte, Nested_comments: No
#cct Merge_duplicate_strings: Yes, Floating_point: Emulation
#cct Optimize: Speed, Char_type: Signed, Standard_stack_frame: Off
#cct Test_stack_overflow: No, Use_registers: Yes
#cct Register_optimization: No, Map_file: Off
#cct Jump_optimization: On, Source_debugging: No, Line_Numbers: Off
#cct End: cct
*/

#include

main ()
{
printf("Hello, world\n");
}

------------------------------------------------------------------------------


After CCT has finished scanning the source code, it will then spawn off TCC
with all of the needed command line switches from your #cct directives. CCT

is relatively smart about the switches; for example, if you specify "Model:
Small", CCT will not put "-ms" onto the command line, since small model is
TCC's default setting. This helps by keeping the command line smaller, since
there is a 128-byte limit on the length of the command line.



The valid switches
------------------

All switches are specified in the format of "switch: setting", where
"switch" is a compiler-directive keyword, and "setting" is either "ON" or
"OFF" (or "YES"/"NO") or a text string.

Here is the list of the supported keywords and their possible settings:


#cct Compiler: x:\path\tcc.exe

Specifies the location and name of the TCC compiler. You only
need to specify this if you don't have TCC somwhere in your
PATH specification.


#cct Main_file: filename.c

This option is rarely ever used; if it is present, the filename
specified will be the main .C name passed to the TCC compiler.


#cct Output: filename.exe

This option allows you to specify the final executable file's
name. It is not needed unless you want to name the final EXE
file something different that the input .C filename.


#cct Link: filename.obj

This directive specifies additional object modules that you need
to link with. Each object module must have its own LINK: keyword.
For example, if your program name is prog_A.c, but you also need
to link with the files prog_B.obj and prog_C.obj, you would do:

#cct link: prog_b.obj, link: prog_c.obj


#cct Model: TINY | SMALL | MEDIUM | COMPACT | LARGE | HUGE

This directive sets the memory model for this compile.


#cct Ansi: ON | OFF

Specifies whether you want an Ansi-compatible compile.


#cct Align: BYTE | WORD

Specifies whether you want byte-alignment or word-alignment.


#cct Nested_comments: ON | OFF

Specifies whether nested comments should be allowed or not.


#cct Merge_duplicate_strings: ON

Specifies whether the compiler should merge identical strings.


#cct Floating_point: NONE | EMULATION | 8087

Specifies the type of floating point support you need.


#cct Optimize: SIZE | SPEED

Allows you to optimize for either speed or size.


#cct Include: \path\name
#cct Lib: \path\name

With these directives, you can specify the paths where the TCC
include files and library files reside.


#cct Char_type: SIGNED | UNSIGNED

Specifies whether "char" types should be signed or unsigned by
default.


#cct Standard_stack_frame: ON | OFF

Specifies whether the compiler should generate standard stack
frames.


#cct Test_stack_overflow: ON | OFF

Specifies whether or not you want the compiler to generate code
to check for stack overflow at entry to each function call.


#cct Calling_convention: C | PASCAL

Specifies the type of calling convention to use.


#cct Use_registers: ON | OFF

Tells the compiler whether it should use register variables
or not.


#cct Register_optimization: ON | OFF

Specifies whether the compiler should attempt to optimize
register variables.


#cct Code_type: 8086 | 8088 | 80286 | 80386

Specifies the type of code the compiler should produce.


#cct Map_file: ON | OFF

Specifies whether a map file should be produced.


#cct Jump_optimization: ON | OFF

Specifies whether the compiler should perform jump optimization.


#cct Generate_underbars: ON | OFF

Tells the compiler if it should use underbars; you'll probably
always use this in the ON position.


#cct Source_debugging: ON | OFF

Turn this switch ON if you are going to be running your output
EXE file with the debugger.


#cct Line_Numbers: ON | OFF

Same as "source_debugging"; turn to ON if you will be running
with the debugger.


#cct end: CCT

This directive tells CCT that it won't find any more #cct
lines in the source file; it simply speeds the process up a little
bit, since CCT won't continue reading lines of the source code.



Wrap up
-------

Well, I think that just about covers everything. This program is for use
free of charge, but as always, I gladly accept donations if you feel that the
program is worth it. If you'd like to send a donation or a letter to me, you
can mail it to:


Keith Ledbetter
4240 Ketcham Drive
Chesterfield, VA 23832


If CCT in any way makes your life easier, I'd appreciate it if you would
drop me an electronic mail (or US Mail) letting me know about it. Sometimes
those of us who crank out these application-specific utilities never really
know whether they are being used by people or not - so just a quick note would
be great.


You can contact me electronically at the following places:


GEnie : ORION.MICRO

Blue Ridge Express BBS: Keith Ledbetter
(804-790-1675)


I have included the source code to CCT in this ZIP file. It is fairly
well commented, so I'm not going to talk about it here. If you modify the
source code to add additional features, I'd appreciate it if you would send
me a copy of the modified source code so that I can keep mine up to date.


As always, Enjoy!

Keith Ledbetter


 December 18, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)