@Smalovsky:
I was able to confirm this issue for fpc 3.2.2. I have not checked if it is already fixed in fpc trunk (the default os alignment for records should usually take care of this)
It is indeed an alignment issue for the record structure TCyberModeNode in unit cybergraphics (OS4units).
In order to fix it you have to change that structure to a
packed record.
Currently you can use two options to workaround the issue:
1: declare the fixed correct structure inside your program
2: copy the cybergraphics.pas header-file next to your project and in that copied file, fix the record structure. During compilation the compiler will then automatically pick up on the (modified/fixed) cybergraphics unit in your project directory first.
So for example, for using the workaround inside a project you could use:
program ListCGFXModes;
uses
exec, agraphics, cybergraphics;
type
PCyberModeNode = ^TCyberModeNode;
TCyberModeNode = packed record // <--- make it a packed record
Node: TNode;
ModeText: array[0..DISPLAYNAMELEN - 1] of Char; // name for this mode
DisplayID: ULONG; // display id associated with the node
Width: UWORD; // visible width
Height: UWORD; // visible height
Depth: UWORD; // display depth
DisplayTagList: PTagItem; // taglist with extended ModeID information
end;
procedure ListModes;
var
nodeList: PList;
node: PNode;
cgxNode: PCyberModeNode absolute node;
begin
nodeList := AllocCModeListTagList(nil);
if assigned(nodeList) then
begin
node := nodelist^.lh_head;
while assigned(node^.ln_succ) do
begin
write('Mode = ' , cgxNode^.ModeText);
write(' Width = ', cgxNode^.Width);
write(' Height = ', cgxNode^.Height);
write(' Depth = ', cgxNode^.Depth);
writeln;
node := node^.ln_succ;
end;
FreeCModeList(nodeList);
end
else
writeln('Unable to obtain CGFX Mode list');
end;
begin
ListModes;
end.
Also note the use of a more correct way to travers the nodelist (for more information about exec lists and how to use them see
here and in particular
this) as well as freeing the allocated list.
As written by alextp, bugs can be reported at gitlab:
https://gitlab.com/freepascal.org/fpc/source/-/issuesSorry for me to keep corresponding in English, I meant no disrespect by doing so (I just can't read/write Russian and I do not like butchering my response by using a online translator). Thank you for reporting !