Delphi Compiler Error
E2146 Default values must be of ordinal, pointer or small set type
Reason for the Error & Solution
You have declared a property containing a default clause, but the type property type is incompatible with default values.
program Produce; type VisualGauge = class pos : Single; property Position : Single read pos write pos default 0.0; end; begin end.
The program above creates a property and attempts to assign a default value to it, but since the type of the property does not allow default values, an error is output.
program Produce; type VisualGauge = class pos : Integer; property Position : Integer read pos write pos default 0; end; begin end.
When this error is encountered, there are two easy solutions: the first is to remove the default value definition, and the second is to change the type of the property to one which allows a default value. Your program, however, may not be as simple to fix; consider when you have a set property which is too large – it is this case which will require you to carefully examine your program to determine the best solution to this problem.