mderie 1 Posted September 2, 2021 Hi folks, I've discover this a bit by misluck : function GenerateAppGUID: TGuid; const guid : TGUID = '{481E85E5-3874-4FCB-BEA1-B65D640AE6D3}'; begin result := guid; // Compile fine ! end; function GenerateAppGUID: TGuid; begin Result := '{481E85E5-3874-4FCB-BEA1-B65D640AE6D3}'; // E2010 Incompatible types: 'TGUID' and 'string' end; I find this quite annoying... Regards Share this post Link to post
Lajos Juhász 293 Posted September 2, 2021 12 minutes ago, mderie said: I find this quite annoying... Why is it annoying? TGUID is not a string. You can write your function as: function GenerateAppGUID: TGuid; begin Result := StringToGUID('{481E85E5-3874-4FCB-BEA1-B65D640AE6D3}'); end; Share this post Link to post
Uwe Raabe 2057 Posted September 2, 2021 Recent Delphi versions also allow this construct: function GenerateAppGUID: TGuid; begin Result := TGUID.Create('{481E85E5-3874-4FCB-BEA1-B65D640AE6D3}'); end; Share this post Link to post
mderie 1 Posted September 2, 2021 It is annoying since the compiler do the type conversion in the declaration and not in the assignement ! Share this post Link to post
Uwe Raabe 2057 Posted September 2, 2021 Filing a feature request may be helpful. Share this post Link to post
Arnaud Bouchez 407 Posted September 2, 2021 Using a local TGUID constant seems the best solution. It is clean and fast (no string/hex conversion involved, just copy the TGUID record bytes). No need to make anything else, or ask for a feature request I guess, because it would be purely cosmetic. Share this post Link to post