I'm working on a solution that should work in C++-Builder and Delphi, that's why I use Object Pascal syntax, but I'm not very familiar with it. I try to access a file mapping with a size that is not defined at runtime with Free Pascal/Delphi. I tried
type
TFileMappingLayout = packed record
Size: DWORD;
Data: array [0..0] of byte;
end;
PFileMappingLayout = ^TFileMappingLayout;
but I'm not sure if this is conform with range checking. It seems to be impossible to google for it, I found nothing useful so far. Reading descriptions about creating structured types did not mention cases like this. I also had a look into the Lazarus source code, but I gave up after 100 trivial record definitions...
I use the Data
field only for binary copying, for instance, writing to it:
PFileMappingLayout(FData)^.size := cbData;
Move(myData, PFileMappingLayout(FData)^.Data, cbData);
How is this normally done in Delphi/Free Pascal?
How would you name this kind of record definition (open record, partial record)?