Next: , Previous: , Up: Top   [Index]


Invoking

Invoking Ctalk

Ctalk has two parts: a preprocessor and interpreter that translates Ctalk code into C, which a compiler can use to create an executable program, and a run-time library, which the compiler links with the executable.

Ctalk has its own C99 compatible preprocessor, ctpp, which is described in its Texinfo manual, ctpp.info.

To use ctalk, you must provide at least the name of the input file. Normally, you also provide the name of the output file with the ‘-o’ option. If you use the conventions followed by GNU C, the output file is normally the base name of the input file with the extension ‘.i’, as in this example.

$ ctalk myprog.c -o myprog.i

The ctalk program preprocesses myprog.c and translates it into standard C. After ctalk has finished, you can compile and link the output of ctalk to produce an executable program.

$ gcc myprog.i -o myprog -lctalk

More conveniently, the ctcc command combines these operations, with the appropriate command line options, to build an executable program.

$ ctcc myprog.c -o myprog

If you need to build a program for debugging, the ctdb command builds executables that you can debug with gdb. See Debugging.

For more information, refer to the ctalk(1), ctcc(1), ctdb(1), gcc(1), and gdb(1) manual pages.

Command Line Options

--clearpreload

Clear preloaded methods so they can be rewritten.

-E

Preprocess the input and exit.

-h, --help

Print a help message and exit.

-I dir

Add dir to the ctalk include search path.

--keeppragmas

Write pragmas untranslated to the output.

--nolibinc

Do not include Ctalk’s system headers in the output.

--nopreload

Do not use preloaded methods.

-o file

Write the ctalk output to file.

--printlibdirs

Print the library directories and exit.

--printtemplates

Print the templates that Ctalk loads and caches (but does not necessarily send to the output).

--progress

Print dots to indicate Ctalk’s progress.

-P

Do not output line number information.

-s dir

Add dir to the compiler system include search path.

-V

Print the Ctalk version number and exit.

-v
--verbose

Print verbose warnings. This option also sets the --warnextension, --warnduplicatenames and --warnunresolvedselexpr options.

--warnclasslibs

Print the names of class libraries as they are loaded.

--warnduplicatenames

Print a warning when an object duplicates a C variable name. Because of the way Ctalk’s just-in-time interpreter works, the front end prints warnings of any duplicate names. The variables and objects need not be in the same scope. Usually, though, Ctalk can make an intelligent decision about how to process objects and variables with duplicate names. This option does not affect errors caused by duplicate symbols or shadowing.

--warnextension

Print warnings for some compiler extensions.

--warnunresolvedselfexpr

Prints warnings if self appears in an argument block with either an instance variable label or an unresolvable method label following it. In expressions like these, the class of each element of a collection, when represented by self within the argument block, often can’t be determined until run time.

You can specify a class for self by placing a class cast expression (described in the section Class casting) before the self keyword. See Class casting.

For example, if a program contains an expression like this:


List new textLines;

   ...The program adds items to textLines...

textLines map {

  if (self length > 0) {

    ...do something...

  }

}

Then the expression, self length would generate a warning due to the label, length, because the class membership of, self, which represents each successive element of the, textLines, list, normally isn’t determined until run time, and so the receiver class of length is also undetermined.

However, if you know that textLines contains only String objects, then you can add a class cast expression in the argument block.


textLines map {

  if ((String *)self length > 0) {

    ...do something...

  }

}

This tells the program to treat length's receiver, self, as a String object, so it’s possible to determine, before the program is actually executed, whether, self length, is a valid expression.


Next: , Previous: , Up: Top   [Index]