Debugging macros, Primitives for showing output – Crunch CRiSP File Editor 6 User Manual

Page 30

Advertising
background image

Page 30

case 1:
case 2:
do_something();
break;
case 3:
case 4:
do_something_else();
break;
}

The statement-list associated with a case statement may consist of zero or more statements, and may
optionally be enclosed in braces, e.g. to allow declaration of local variables:

switch (expr) {
case 1: {
int i;
i = 3 * 4;
break;
}
...
}

The break statement may be used to terminate the switch statement.

The switch statement has a bug associated with it. Consider the following example:

int i = 0;
switch (1) {
case 1:
i++;
case 2:
i++;
break;
}

In the C, language, i will have the value of 2 after executing the switch statement. In crunch, i will have the
value 1. This is because crunch does not currently support the flow-thruoughfacility of C. This may be
considered a bug, and user code should not rely on this as it is liable to change in future versions of the
language and compiler. (The CRiSP supplied macros do rely on this feature and are wrong!).

{button See Also, ALink(crunch,,,)}

Debugging macros

CRiSP provides a number of facilities to aid in debugging of macros and tracing execution. There is no
complete debugger environment but there are various mechanisms to help in tracing why a macro does not
work properly. The following sections describe the features that are currently available.

Apart from the BRIEF compatible functions, these debugging features are subject to change in future
versions of CRiSP. Eventually CRiSP will contain sophisticated macro debugging facilities, but the focus has
been so far to improve the editing environment for end users.

Primitives for showing output.(pg. 30).

Macro tracing(pg. 31).

Debugging a function(pg. 32).

Debug on startup(pg. 32).

Debug buffering(pg. 33).

Monitoring variables(pg. 33).

Primitives for showing output

CRiSP CRiSP provides various primitives which are using when following the progress of a macro. These
primitives and macros allow you to display messages to stdout or to the status area.

printf()

This function is similar to the standard C library printf() function. It is used to display

Advertising