Warning on comparing a SmallInt with result of Ord function

Viewed 380

I'm comparing a SmallInt variable with the result of the Ord function. Example:

var
  MySmallInt : SmallInt;
begin
  MySmallInt := 5;
  if(MySmallInt > Ord('C'))
  then ShowMessage('True')
  else ShowMessage('False');
end

After doing this, the following warning message is shown (W1023):

W1023 Comparing signed and unsigned types - widened both operands

Delphi's hint on the Ord function says that it should return a SmallInt and that's why I can't understand what causes the warning message. (I've looked for Ord function in the System unit but I didn't find it).

enter image description here

Further Informations:

  • I'm testing under Delphi XE7.
  • Under Delphi 2007, the same code doesn't give me any warning.
2 Answers
Related