Function Definition
#pragma TEST_CODE CompOp <Size> {<HashCode>}
CompOp: ==|!=|<|>|<=|>=
<Size>: Size of the function to be used with compare operation
<HashCode>: Optional value specifying one specific code pattern.
None
This pragma checks the generated code. If the check fails, the Compiler issues message C3601.
This pragma tests the following items:
Compares the compare operator and the size given as arguments with the size of the function.
This feature checks whether the compiler-generated code is more or less than a given boundary. To check only the hashcode, use a condition which is always TRUE, such as != 0.
The compiler generates a 16-bit hashcode from the 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 fail). Then copy the computed hashcode out of the body of message C3601.
The following listings 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, as shown in 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