[fpc-pascal] How to solve "variable does not seem to be
initialized" compiler hint.
joshyfun at gmail.com
Thu Nov 19 10:16:36 CET 2009
Thursday, November 19, 2009, 8:52:41 AM, you wrote:
GG> And working with a uninitialized data structure is a good thing? I think
GG> not. So, like everybody else, I manually initialise my data structures -
GG> and because of my efforts to write safer code, the compiler gives me a
GG> hint "variable does not seem to be initialized". The exact opposite of
GG> what I was trying to do. So that hint is useless, after I really did fix
GG> the potential problem in code. The problem is simply FillChar that uses
GG> the wrong parameter type - var instead of out.
Its for sure that this discussion will end up in a dead point, things
should be different ? Maybe yes. Will it be changed ? No to avoid
problems. So as the compiler will issue hints about uninitialized data
and FillChar is not the right procedure to initialize nothing except
maybe a short string (due its name), why not create some procedures to
initialize arrays and memory blocks with a more 21th century names ?
Something like "InitializeArray" and "InitializeRecord". Would it
require compiler magic ?
From my point of view FillChar name does not match a initialize data
function. FillMemory (in wininc) is more clear but also it does not
"initialize" a string.
GG> And now Jonas says the problem cannot be fixed simply because of the
GG> select few developers working on Windows+COM projects. The the problem
GG> must now be accepted by all because of a VERY specific use-case. That
GG> doesn't sound very "cross platform" to me??
out parameters seems to have a "difficult to predict" effects on some
types, I think interfaces could be affected by out parameters also and
anything that it's auto-freed by the compiler.
More information about the fpc-pascal