#pragma TEST_CODE: Check Generated Code

Scope

Function Definition

Syntax
  #pragma TEST_CODE CompareOperator <Size> [<HashCode>] 
  
  CompareOperator: ==|!=|<|>|<=|>= 
  
Arguments

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

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

Default

None

Description

This pragma checks the generated code. If the check fails, the message C3601 is issued.

The following parts are tested:

Examples

The following listing and Listing: Using a Test_Code pragma with the hashcode option 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 (refer to the following listing).

Listing: Using a Test_Code pragma with the hashcode option


/* 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 in the Online Help