Delphi: array of Char and TCharArray "Incompatible Types" -


i've run across "incompatible types" error in comment below few times, , never been happy why isn't directly supported in delphi 2007:

program project1; {$apptype console}  type tchararray = array of char;  procedure doarray(chars: array of char); begin end;  function returntchararray: tchararray; var chararray: tchararray; begin   result := chararray; end;  begin   doarray(returntchararray); // [dcc error] project1.dpr(18): e2010 incompatible types: 'array' , 'tchararray' end. 

shouldn't possible make array type "aliased" array type compatible each other? assuming can't change declaration of doarray (it part of third party library), how write function returning array of char compatible doarray's param? straightforward "function returnachar: array of char;" results in "identifier expected 'array' found" error. tried changing function returning array procedure var "array of char" pram, doesn't allow setting length of "array of char" param in procedure ("constant object cannot passed var parameter").

this may compiler bug (or limitation never documented properly). did experimentation , found can pass dynamic array (typed or not) procedure expecting open array every type... except char , widechar.

see is dynamic array of char allowed when parameter type open array of char? description of problem , possible work around.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -