char type problem

Top  Previous  Next

What is not translated > char type problem

 

The char type in C++ is a signed type, whereas it is an unsigned type in Object Pascal. It is rare that a situation would occur in which this difference would be a problem. A customer sent me the following example:

 

  var c : Char;

  c := someUpperAsciiValue;

  if c < #32 then

    ; // c is between 0 and 31.

 

gets converted to:

 

  char c;

  c = someUpperAsciiValue;

  if (c < '\x20')

    ; // c is between -127 and 31.

 

He has fixed the code by casting c to Byte there.



This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content