#pragma TEST_CODE: Check Generated Code

Scope

Function Definition

Syntax
  #pragma TEST_CODE CompOp <Size> {<HashCode>}   
  CompOp: ==|!=|<|>|<=|>=   
Arguments

<Size>: Size of the function to be used with compare operation

<HashCode>: Optional value specifying one specific code pattern.

Default

None

Description

This pragma checks the generated code. If the check fails, the Compiler issues message C3601.

This pragma tests the following items:

To get the hashcode of a certain function, compile the function with an active #pragma TEST_CODE (which will fail). Then copy the computed hashcode out of the body of message C3601.

Note: The code generated by the compiler may change. Test failure may indicate that the test results are unclear.
Examples

The following listings present two examples of the TEST_CODE pragma.

Listing: Using TEST_CODE to Check the Size of Generated Object Code
/* check that an empty function is smaller */
/* than 10 bytes */

#pragma TEST_CODE < 10

void main(void) {

}

You can also use the TEST_CODE pragma to detect when a different code is generated, as shown in the following listing.

Listing: Using a Test_Code Pragma with a Hashcode
/* If the following pragma fails, check the code. */
/* If the code is OK, add the hashcode to the */

/* list of allowed codes : */

#pragma TEST_CODE != 0 25645 37594

/* check code patterns : */

/* 25645 : shift for *2 */

/* 37594 : mult for *2 */

void main(void) {

  f(2*i);

}
See also

Message C3601