<div dir="ltr"><div><div>Hello,</div><div><br></div><div>Recently I've made a class to generate error log for codes in Delphi and Free Pascal. It works capturing the class name where the problem occurred, adding the date/time concatenated with the error message. It's working perfectly in Delphi.</div><div><br></div><div>The problem is in Free Pascal and in your approach to save the name of specialized classes. They are very weird names and a little intuitive. For example:</div><div><br></div><div><font size="1">TFoo$1$crcB96581A6</font></div><div><br></div><div>Assuming the small code below is my log generator, see the output generated by Delphi code:</div><div><br></div><font size="1">program Project1;<br><br>{$APPTYPE CONSOLE}<br><br>uses<br>  System.SysUtils;<br><br>type<br>  TTest = class(TObject)<br>  end;<br><br>  TFoo<T> = class(TObject)<br>  public<br>    class procedure Log(AClass: System.TClass);<br>  end;<br><br>  TBar1 = TFoo<TTest>; // short declaration<br><br>  TBar2 = class(TFoo<TTest>) // full declaration<br>  end;<br><br>  class procedure TFoo<T>.Log(AClass: System.TClass);<br>  begin<br>    System.WriteLn('[', System.SysUtils.FormatDateTime('hh:nn:ss.zzz',<br>      System.SysUtils.Now), ']: ', AClass.ClassName);<br>  end;<br><br>begin<br>  TFoo<TTest>.Log(TBar1);<br>  TFoo<TTest>.Log(TBar2.ClassParent);<br>  System.ReadLn;<br>end.</font><div><br></div><div>Output:</div><div><br></div><div><div><font size="1">[06:27:08.545]: TFoo<Project1.TTest></font></div><div><font size="1">[06:27:08.546]: TFoo<Project1.TTest></font></div></div><div><br></div><div>Now, see the same output for a Free Pascal code:</div><div><br></div><div><div><font size="1">program Project1;</font></div><div><font size="1"><br></font></div><div><font size="1">{$mode delphi}</font></div><div><font size="1"><br></font></div><div><font size="1">uses</font></div><div><font size="1">  SysUtils;</font></div><div><font size="1"><br></font></div><div><font size="1">type</font></div><div><font size="1">  TTest = class(TObject)</font></div><div><font size="1">  end;</font></div><div><font size="1"><br></font></div><div><font size="1">  TFoo<T> = class(TObject)</font></div><div><font size="1">  public</font></div><div><font size="1">    class procedure Log(AClass: System.TClass);</font></div><div><font size="1">  end;</font></div><div><font size="1"><br></font></div><div><font size="1">  TBar1 = TFoo<TTest>; // short declaration</font></div><div><font size="1"><br></font></div><div><font size="1">  TBar2 = class(TFoo<TTest>) // full declaration</font></div><div><font size="1">  end;</font></div><div><font size="1"><br></font></div><div><font size="1">  class procedure TFoo<T>.Log(AClass: System.TClass);</font></div><div><font size="1">  begin</font></div><div><font size="1">    System.WriteLn('[', SysUtils.FormatDateTime('hh:nn:ss.zzz',</font></div><div><font size="1">      SysUtils.Now), ']: ', AClass.ClassName);</font></div><div><font size="1">  end;</font></div><div><font size="1"><br></font></div><div><font size="1">begin</font></div><div><font size="1">  TFoo<TTest>.Log(TBar1);</font></div><div><font size="1">  TFoo<TTest>.Log(TBar2.ClassParent);</font></div><div><font size="1">  System.ReadLn;</font></div><div><font size="1">end.</font></div></div><div><br></div><div>Output:</div><div><br></div><div><div><font size="1">[06:27:08.545]: TFoo$1$crcB96581A6</font></div><div><font size="1">[06:27:08.545]: TFoo$1$crcB96581A6</font></div></div><div><br></div><div>It is very weird this generated class names. The Free Pascal will continue to use these weird names or there are plans to improve this in future versions? With names like that is almost impossible to create automated error logs structures with Free Pascal.</div><div><br></div><div>Thank you!</div></div><div><br>-- <br><div>Silvio Clécio<br>My public projects - <a href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a></div>
</div></div>