Delphi warning - W1002 Symbol 'FileSetDate' is specific to a platform
Asked Answered
K

3

19

When I compile my application under Delphi 2006 I get the following warning [Pascal Warning]- W1002 Symbol 'FileSetDate' is specific to a platform

What must I do to suppress this warning?

The code

MyLastError:= FileSetDate( Files[ i ].Handle, DateTimeToFileDate( arcDate ) );
Klee answered 9/12, 2008 at 11:42 Comment(0)
B
25

Although the answer of DR solves the warning, it is not the correct solution.

You should use the platform independent version of FileSetDate:

function FileSetDate(const FileName: string; Age: Integer): Integer; overload;

Also in SysUtils.

Berry answered 9/12, 2008 at 12:33 Comment(0)
E
28

1) In the project options you can choose the compiler messages you want to see. If you don't care about platform independency you can just switch off the platform warning there.

2) Another way is disabling the warning for a certain part of the code:

{$WARN SYMBOL_PLATFORM OFF}
// Your code
{$WARN SYMBOL_PLATFORM ON}

For a complete list of options look at the Delphi help file at the topic '$WARN'

3) A last way would be adding

{$WARNINGS OFF}
// Your code
{$WARNINGS ON}

but that is dangerous, because all warnings will be suppressed.

4) Additionally, as the other answers have already suggested, you could just switch to the platform independant variant of FileSetDate which works on file names (i.e. Strings), but as far as I understand that was not your question.

Eatmon answered 9/12, 2008 at 11:48 Comment(0)
B
25

Although the answer of DR solves the warning, it is not the correct solution.

You should use the platform independent version of FileSetDate:

function FileSetDate(const FileName: string; Age: Integer): Integer; overload;

Also in SysUtils.

Berry answered 9/12, 2008 at 12:33 Comment(0)
R
8

You can turn off the platform unit and platform symbol compiler warnings. They are obsolete (and disabled in Delphi 2009 by default). They were introduced when there was a Delphi for Linux (Kylix). They do not have a meaning anymore. Especially with the replacement of Delphi.NET with Delphi Prism. You can turn them off for the whole project in the Project Options dialog (Compiler Messages).

Rubenstein answered 9/12, 2008 at 11:57 Comment(2)
Just a note that there are valid warnings for code compatible with Vista+ that is not compatible with XPMarshamarshal
Actually this is not true anymore. With the latest versions of Delphi, that can compile for Win32, Win64, Mac, iOS and Android... this warning has its use once more.Montcalm

© 2022 - 2024 — McMap. All rights reserved.