[fpc-pascal] The unfortunate deprecation of GetTickCount

Karoly Balogh (Charlie/SGR) charlie at scenergy.dfmk.hu
Wed Apr 11 19:23:37 CEST 2018


Hi,

On Wed, 11 Apr 2018, Michael Van Canneyt wrote:

> >> personally I use this 64 bit emulation:
> >
> > For my purpose I'm perfectly happy with GetTickCount. I'd understand the
> > deprecation if GetTickCount64 would be a reliable substitute. It isn't.
>
> Only on XP. On all other platforms, it is the better solution.

Actually... I kinda disklike this depreciation too. Better is just such a
bad word for software engineering. (Almost) everything has its purpose.

GetTickCount is clearly a Windows API function, does not directly exist in
Delphi itself, so this is an FPC addition to the Sysutils unit for
Delphi-compatible platform idependence - and to my knowledge, Microsoft
did not deprecate the 32bit variant, instead it documented that it rolls
over after 49.7 days, which we could also do just fine.

Especially because extending the result to 64bit is *NOT* the only way to
get around the 32bit overflow problem of a timer, and for a lot of
purposes it's perfectly fine, especially on 32bit systems, which are still
numerous.

Which means, the workaround for the deprecation message on Windows is
actually using the GetTickCount from Windows unit directly, which is
supported everywhere and even Delphi compatible (no GetTickCount/64 in
sysutils there, according to the docs I can find, but fix me?).

BTW, for additional fun, the Windows RTL system unit itself still uses
the 32bit Windows API GetTickCount to initialize its RandSeed...

Charlie


More information about the fpc-pascal mailing list