Delphi Compiler Error
E2033 Types of actual and formal var parameters must be identical
Reason for the Error & Solution
For a variable parameter, the actual argument must be of the exact type of the formal parameter.
program Produce; procedure SwapBytes(var B1, B2 Byte); var Temp: Byte; begin Temp := B1; B1 := B2; B2 := Temp; end; var C1, C2 0..255; (*Similar to a byte, but NOT identical*) begin SwapBytes(C1,C2); (*<-- Error message here*) end.
Arguments C1 and C2 are not acceptable to SwapBytes, although they have the exact memory representation and range that a Byte has.
program Solve; procedure SwapBytes(var B1, B2 Byte); var Temp: Byte; begin Temp := B1; B1 := B2; B2 := Temp; end; var C1, C2 Byte; begin SwapBytes(C1,C2); (*<-- No error message here*) end.
So you actually have to declare C1 and C2 as Bytes to make this example compile.