Predefined macro
This macro processes error messages returned from a macro. The error macro generates a call to the error processing function (_error). It handles messages from both predefined and user-specified macros.
The message and value parameters are formatted in standard PRINTF formats.
Syntax:
int
error (type, message,
value)
int type;
char *message;
long value;
where:
type Variable of type int. Specifies the error class, indicated by a predefined error code:
|
Type |
Class |
Description |
|
1 |
note code |
message appears in the Output pane as a line with no prefix. |
|
2 |
warning code |
message appears in the Output pane as a highlighted line with the prefix Warning:. |
|
3 |
error code |
message appears in an Error dialog. |
message Pointer to char. Points to the first character in a character string for the corresponding error message.
value Variable of type long.
Return Value
int Indicates the error message that is displayed in the Code window.
Rules
See the PRINTF command for value formats.
Example
Define the macro int odd(n):
int n;
{
if ((n
& 0x1)==1) /* check if number is odd, using
bitwise
AND, and checking for
nonzero result */
return (0); /*
zero is returned from this branch,
indicating: Yes, number is odd.*/
else /* no - number is even, not odd */
error (2, "number specified (%d) is not odd\n", n);
/* text
msg displayed,
%d in format
specifier used for int
display,
as in printf()
*/
return (1); /*
1 is returned when exiting this
branch */
}
Enter odd(6)
The following error message appears in the Output pane:
Warning: number specified (6) is not odd