Function Definition
#pragma TEST_CODE CompareOperator <Size> [<HashCode>]
CompareOperator: ==|!=|<|>|<=|>=
<Size>: Size of the function to be used in a compare operation
<HashCode>: optional value specifying one specific code pattern.
None
This pragma checks the generated code. If the check fails, the message C3601 is issued.
The following parts are tested:
The compare operator and the size given as arguments are compared with the size of the function.
This feature checks that the compiler generates less code than a given boundary. Or, to be sure that certain code it can also be checked that the compiler produces more code than specified. To only check the hashcode, use a condition which is always TRUE, such as != 0.
The compiler produces a 16-bit hashcode from the produced code of the next function. This hashcode considers:
To get the hashcode of a certain function, compile the function with an active #pragma TEST_CODE which will intentionally fail. Then copy the computed hashcode out of the body of the message C3601.
The following listing and Listing: Using a Test_Code pragma with the hashcode option present two examples of the TEST_CODE pragma.
/* 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).
/* 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); }
Message C3601 in the Online Help