[fpc-pascal] Initializing records and other complicated structures
    Jim 
    hakkie42 at gmail.com
       
    Mon Sep 27 10:26:45 CEST 2010
    
    
  
Hi,
Fpc sometimes complains (hints) about local variables not being initialized.
My question: how do I initialize more complicated structures like
records? And should I need to (I'm guessing no in the example below, but
the contents of the record will be undefined - no problem as there are
no pointers/strings in there)?
Example:
....
Type
  TIfdTag = packed Record
    ID: word;
    //Tag number
    Typ: word;
    //Type tag
    Count: cardinal;
    //tag length
    Offset: cardinal;
    //Offset / Value
  End;
....
Var
  tag: TIfdTag;
....
in code somewhere
               ReadTag(tag);
As TIfdTag seems to contain non-pointer records only, I thought I could
use Sizeof and tried this:
FillByte(tag, SizeOf(tag), 0); //initialize var.
The compiler warning doesn't go away though.
Is this the recommended way of doing things?
Thanks,
-- 
Regards,
jb
    
    
More information about the fpc-pascal
mailing list