[fpc-pascal] How to solve "variable does not seem to be initialized" compiler hint.

Graeme Geldenhuys graeme at mastermaths.co.za
Thu Nov 19 07:35:32 CET 2009

Cox, Stuart TRAN:EX wrote:
> The _proper_ solution is to initialize the variable's contents and
> then use it.  The alternative is to substitute an alternative

That was the whole point about this thread. I used uninitialized
varibles and the compiler correctly hinted about it. I then made use of
FillChar to initialize those structure types, but then to my surprise
the actual code I wrote to initialize thsoe variables were now the
source of that hint!

I still don't think this is right and I still think FillChar must be
changed to out, at least in 'objfpc' mode. The first parameter in
FillChar gets initialized by FillChar, so NO hint must be given. That's
the whole point of FillChar.

As I know the work-around is yet another wrapper function (which I have
done), but the source of the problem still exists.

Somebody did once attempt to correct the var parameter to out parameter
in FillChar, but got to many errors. Probably not a high priority issue,
so the problem was simply swept under the rug.

As for the COM usage requirement (which I honestly believe is the
minority use case in FPC). Then create a different FillChar -type
procedure to handle those corner cases, or create a different procedure
which allows structure types to be initialized without compiler hints.

  - Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal

More information about the fpc-pascal mailing list