3.2.8. error

Processes an error message returned from a macro.

Syntax:

int error (type, message, value)
int type; 
char *message;
long value;

where:

type

Specifies the error class indicated by one of the predefined error codes listed in Table 3.9.

Table 3.9.  Error classes

TypeClassDescription
1note

message appears as a line with no prefix.

In the GUI, the message appears in the Output view.

2warning code

message appears with the Warning: prefix.

In the GUI, the message appears in the Output view and is also highlighted.

3error code

In the headless debugger message appears with the Error: prefix.

In the GUI, message appears in an Error dialog without the prefix.


message

Pointer to char. Points to the first character in a character string for the corresponding error message.

The string can contain a single instance of the format specifier %d. In this case, value is printed in the string. If no format specifier is included in the string, value is ignored.

value

Variable of type long.

Description

This macro processes an 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.

Return Value

int

Indicates the error message that is displayed in the Cmd tab of the Code window.

Rules

Uses the same value formats as the PRINTF command.

Example

Do the following:

  1. Define the following macro in a command script file, and load the file:

    DEFINE /R int odd(n)
      int n;
    {
      if ((n & 0x1)==1) // check if number is odd, using
                        // a 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
    }
    .
    
  2. Enter the command:

    odd(6)
    

    The following error message appears:

    Warning: number specified (6) is not odd
    

See also

Copyright © 2002-2009 ARM Limited. All rights reserved.ARM DUI 0175K
Non-Confidential