0

I'm trying to compile an old Turbo C++ package with C++ Builder compiler (Rad Studio 10.2).

During this, I got error:
[bcc32 Error] E2357 Reference initialized with 'char', needs lvalue of type 'wchar_t'
connected with this block of code:

void __fastcall TRsEdit::KeyPress(char &Key)
{

   bool ok = true;

   if ( ! IsNumber(Key))
   {

      if (! IsTabOrReturn(Key))
         ok = false;

   }

   if (!ok && !ComponentState.Contains(csDesigning) )
     Key = 0;

   TEdit::KeyPress(Key); 
}

Error occurs for line: TEdit::KeyPress(Key)

This procedure is declared in Vcl.StdCtrl.hpp file as:

DYNAMIC void __fastcall KeyPress(System::WideChar &Key);

Does anyone know how deal with this problem?

Patrycja
  • 11
  • 3
  • Duplicate? https://stackoverflow.com/questions/3074776/how-to-convert-char-array-to-wchar-t-array – Constantin Iliescu Jul 20 '17 at 14:31
  • 1
    The RTL and VCL switched to Unicode in 2009. `System::Char` and `System::String` were changed from `char`/`AnsiString` to `wchar_t`/`UnicodeString`. As such, `TRsEdit::KeyPress(char &Key)` should be updated to either `TRsEdit::KeyPress(WideChar &Key)` or `TRsEdit::KeyPress(Char &Key)` to match the new signature of `TEdit::KeyPress()` – Remy Lebeau Jul 20 '17 at 18:03
  • Thanks for your help. It works for TRsEdit::KeyPress(WideChar &Key). – Patrycja Jul 24 '17 at 06:44

0 Answers0