<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>I stumbled into a problem I don't understand.</p>
<p>I'm developing a little program for an ftp client. In order to
connect to the site I need the site address from the site name,
and the libc gethostbyname() provides the required information.</p>
<p>gethostbyname returns a PHostEnt type which is declared as:</p>
<p>
<blockquote type="cite"> <font face="monospace"> THostEnt = packed
record<br>
h_name: PChar; { Official name of host.
}<br>
h_aliases: PPChar; { Alias list. }<br>
h_addrtype: Integer; { Host address type. }<br>
h_length: socklen_t; { Length of address. }<br>
case Byte of<br>
0: (h_addr_list: PPChar); { List of addresses from
name server. }<br>
1: (h_addr: PPChar); { Address, for backward
compatibility. }<br>
end;<br>
PHostEnt = ^THostEnt; </font></blockquote>
Actually the chars h_addr points to are <i>hlength</i> bytes to
be interpreted as an <i>in_addr</i> <br>
</p>
<p>In order to recover h_addr I have a line which works perfectly in
Delphi mode (inherited from an old Kylix app):</p>
<p>
<blockquote type="cite"> <font face="monospace">Addr :=
Pin_addr(HostEnt.h_addr^);</font><br>
</blockquote>
I believed that in objfpc mode it was sufficient to change it in</p>
<p>
<blockquote type="cite"> <font face="monospace"> Addr :=
@(Pin_addr(HostEnt.h_addr^));</font><br>
</blockquote>
or in</p>
<blockquote type="cite"> <font face="monospace"> Addr :=
Pin_addr(@HostEnt.h_addr^);</font><br>
</blockquote>
<p></p>
<p>but such is not the case. In both cases it flags the line with
the same error, i.e.:</p>
<font face="monospace">Error: illegal qualifier<br>
Hint: may be pointer dereference is missing<br>
Fatal: Syntax error, ")" expected but "identifier H_ADDR" found<br>
</font>
<p>What I'm missing? How should i write that line of code to make it
work in objfpc mode?</p>
<p>Thanks,</p>
<p>Giuliano</p>
<p><br>
</p>
<p><br>
</p>
<p><br>
</p>
<p><br>
</p>
</body>
</html>