views:

236

answers:

2

I am using a FindFile routine to search through all files in a directory. The original code was freely available from Latium Software. It runs the FindFile is a separate Thread.

It has always worked fine, and still continues to work fine. But since I upgraded from Delphi 4 to Delphi 2009, it now gives a Warning:

W1055: Published caused RTTI ($M+) to be added to type '%s' (Delphi)

The error occurs at the "published" line of this thread declaration:

  TThread1 = class(TThread)
  private
    OwnerForm: TFindFileForm;
    procedure Initialize;
    procedure AddFileName;
    procedure Finalize;
  protected
    procedure Execute; override;
  published
    constructor Create(Owner: TFindFileForm);
    destructor Destroy; override;
  end;

The Delphi help states:

You added a 'PUBLISHED' section to a class that was not compiled while the {$M+}/{$TYPEINFO ON} switch was in effect, or without deriving from a class compiled with the {$M+}/{$TYPEINFO ON} switch in effect.

The TypeInfo standard procedure requires a type identifier as its parameter. In the code above, 'NotType' does not represent a type identifier.

To avoid this error, ensure that you compile while the {$M+}/{$TYPEINFO ON} switch is on, or derive from a class that was compiled with {$M+}/{$TYPEINFO ON} switch on.

Well, I didn't add the 'PUBLISHED' section. It's always been there. I'm not a component developer, and I really don't understand at all what this message means, whether or not it is really a problem, and what I should or should not do about it.

Is this important and if so, what should I do to fix it? Or should I just ignore it?

+3  A: 

It adds some data to the executable and increases its size somewhat. In very rare cases it can be a reverse engineering risk, as it permits third parties (e.g. crackers) to see that the class supports the methods mentioned in the published section.

You can safely ignore it, or replace the published directive with public to make it go away.

Barry Kelly
Thanks, Barry. If I represent a typical Delphi programmer, then error messages such as these are not helpful to us, unless the recommendation of what to do is better. The Help didn't mention anything about changing published to public
lkessler
+7  A: 

Barry's answer deals with the crux of this particular issue, but note that W1055 is not an "error", it's a WARNING (as indicated by the W).

The following prefixes are used in compiler output:

  • Hnnnn - hints
  • Wnnnn - warnings
  • Ennnn - errors
  • Lnnnn - linker errors
  • Unnnn - unexpected(?) internal errors

I've listed these in order of relative severity and significance. Hints and warnings generally don't affect your compilation - they tell you about consequences arising from things in your code.

Errors obviously are errors that prevent compilation. Linker errors are relatively uncommon but indicate that although compilation was successful, something went wrong during linking.

U errors are the bad boys - you get these VERY rarely and they indicate that something went badly or unexpectedly wrong in the compiler itself.

As Barry said - in your case you could ignore 1055, since it is a warning that simply informs you of the consequences of using "published" in the way that it was found in your code. It is generally a good idea to have a policyof "Zero warnings" (or hints) however, as then you can use the presence of a hint OR a warning in your compilation as a "red flag" that indicates a potential mistake in your code (the compiler interpreting something in a way that you perhaps did not intend. e.g. in this case, you didn't MEAN to publish the method and have RTTI introduced onto your class).

Deltics