Macros and Typedefs

Macros

Of the macros defined in the ct.h header file, the first four are defined merely for convenience: Three others define certain operating parameters within Cheap Threads. For a given application it may be useful to modify their values. In each case, ct.h defines the macro only if it is not already defined. Most compilers provide some mechanism to define a macro outside of the source code.

Macro for Timeouts

The code implementing timeouts is disabled by default, in order to avoid incurring the overhead in applications that don't use timeouts. If you want to use timeouts, compile Cheap Threads with the macro CT_TIMEOUT defined.

Macro for ct_return()

The code implementing the ct_return function is disabled by default, in order to avoid incurring the overhead in applications that don't use it. If you want to use ct_return(), compile Cheap Threads with the macro CT_RETURN defined.

Macros for Embedded Cheap Threads

Several macros apply only when using Embedded Cheap Threads to avoid dynamic memory allocation, as described elsewhere. In each case the source code defines a value only if no value has been defined elsewhere, as by a compiler option. Each of these macros defines the size of a static array of objects that may be used and reused at run time. The default values are arbitrary and may not be appropriate for a given application. It is the developer's job to analyze the application carefully to determine appropriate values.

See also the description of CT_MSG_BUF_LEN in the preceding section.

Typedefs

Several of the Cheap Threads functions take function pointers as parameters. Since the syntax of function pointers is rather clumsy and cryptic, the ct.h header provides typedefs for several kinds of function pointer:
Home