[fpc-devel]h2pas bug
Jeff Pohlmeyer
yetanothergeek at yahoo.com
Thu Feb 13 23:05:43 CET 2003
This is legal in a C header:
struct foo;
- But it causes a seg fault in h2pas when it tries
to read the fields from the undefined structure.
There may be a better place to test for this,
but the patch below seems to work:
[PATCH]
--- h2pas-old/h2pas.pas Thu Feb 13 15:20:44 2003
+++ h2pas-new/h2pas.pas Thu Feb 13 15:06:49 2003
@@ -1386,6 +1386,7 @@
end;
shift(3);
(* write new type name *)
+ if ( yyv[yysp-1]^.p2 <> nil ) then begin
TN:=TypeName(yyv[yysp-1]^.p2^.p);
PN:=PointerName(yyv[yysp-1]^.p2^.p);
(* define a Pointer type also for structs *)
@@ -1407,7 +1408,17 @@
write_packed_fields_info(outfile,hp,TN);
if assigned(hp) then
dispose(hp,done);
-
+ end else
+ begin
+ TN:=TypeName(yyv[yysp-1]^.str);
+ PN:=PointerName(yyv[yysp-1]^.str);
+ if UsePPointers then writeln(outfile,aktspace,PN,' = ^',TN,';');
+ writeln(outfile, aktspace, TN, ' = record');
+ writeln(outfile, aktspace, ' {undefined structure}');
+ writeln(outfile, aktspace, ' end;');
+ writeln(outfile);
+ popshift;
+ end;
end;
23 : begin
[/PATCH]
...This will make h2pas print something like:
type
Pfoo = ^Tfoo;
Tfoo = record
{undefined structure}
end;
__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com
More information about the fpc-devel
mailing list