<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>Message</TITLE>
<META content="MSHTML 6.00.6000.16544" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=953024808-30042011>Using
macros, the translation looks like</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT size=2>{$MACRO ON}<BR>{$ifndef
DOCUMENTATION_ONLY}<BR>{$if SU_HAVE_SOCKADDR_SA_LEN <>0}<BR>
{$define su_len:=su_sa.sa_len}<BR>{$else}<BR> {$define
su_len:=su_array[0]}<BR>{$endif}<BR>{$define
su_family:=su_sa.sa_family}<BR>{$define su_port:=su_sin.sin_port}<BR>{$define
su_scope_id:=su_array32[6]}<BR>{$endif}<BR><SPAN
class=953024808-30042011>type</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=953024808-30042011> su_sockaddr_u =
record<BR> case longint of<BR>
{$ifdef
DOCUMENTATION_ONLY}<BR> 0
: ( su_len : byte );<BR> 1
: ( su_family : byte
);<BR> 2 : ( su_port :
word );<BR>
{$else}<BR> 3 : ( su_dummy
: smallint );<BR>
{$endif}<BR> 4 : (
su_array : array[0..31] of char
);<BR> 5 : ( su_array16 :
array[0..15] of word
);<BR> 6 : ( su_array32 :
array[0..7] of longword
);<BR> 7 : ( su_sa :
sockaddr );<BR> 8 : (
su_sin : sockaddr_in
);<BR> {$if SU_HAVE_IN6
<>0}<BR> 9 : (
su_sin6 : sockaddr_in6
);<BR>
{$endif}<BR> {$ifdef
DOCUMENTATION_ONLY}<BR> 10
: ( su_scope_id : longword
);<BR>
{$endif}<BR>
end;<BR></SPAN></FONT></FONT></FONT></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV class=OutlookMessageHeader lang=fr dir=ltr align=left><FONT face=Tahoma
size=2>-----Message d'origine-----<BR><B>De :</B>
fpc-pascal-bounces@lists.freepascal.org
[mailto:fpc-pascal-bounces@lists.freepascal.org] <B>De la part de</B> Ludo
Brands<BR><B>Envoyé :</B> samedi 30 avril 2011 10:29<BR><B>À :</B>
'FPC-Pascal users discussions'<BR><B>Objet :</B> RE : RE : [fpc-pascal]
How to translate this union ?<BR><BR></FONT></DIV>
<DIV><SPAN class=468414907-30042011><FONT face=Arial color=#0000ff
size=2>Forget my previous reply. I found the original header file on
sourceforge. </FONT></SPAN></DIV>
<DIV><SPAN class=468414907-30042011><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=468414907-30042011><FONT face=Arial color=#0000ff size=2>I
have alse a better understanding now of what the code is supposed to do: in
case DOCUMENTATION_ONLY is not defined, a reference to, for example,
su_sockaddr_u.su_family will be subsstituted by su_sockaddr_u.susa.sa_family.
</FONT></SPAN></DIV>
<DIV><SPAN class=468414907-30042011><FONT face=Arial color=#0000ff size=2>You
could use macros and do a {$define su_family:=susa.sa_family} with the
following limitations:</FONT></SPAN></DIV>
<DIV><SPAN class=468414907-30042011><FONT face=Arial color=#0000ff size=2>- if
you have variables or other record members named su_family, not part of the
su_sockaddr_u record, they will be renamed also. </FONT></SPAN></DIV>
<DIV><SPAN class=468414907-30042011><FONT face=Arial color=#0000ff size=2>- it
works only for the units that include your .inc file.</FONT></SPAN></DIV>
<DIV><SPAN class=468414907-30042011></SPAN> </DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV class=OutlookMessageHeader lang=fr dir=ltr align=left><FONT face=Tahoma
size=2>-----Message d'origine-----<BR><B>De :</B>
fpc-pascal-bounces@lists.freepascal.org
[mailto:fpc-pascal-bounces@lists.freepascal.org] <B>De la part de</B> Ludo
Brands<BR><B>Envoyé :</B> samedi 30 avril 2011 09:18<BR><B>À :</B>
'FPC-Pascal users discussions'<BR><B>Objet :</B> RE : [fpc-pascal] How
to translate this union ?<BR><BR></FONT></DIV>
<DIV><SPAN class=078041007-30042011><FONT face=Arial color=#0000ff
size=2>Can you post the original c code? You point to a file that seems to
be a reworked output from h2pas. As it is now, it indeed doesn't make any
sense. I would think the su_len,su_family,su_port should make up a record
but they aren't.</FONT></SPAN></DIV>
<DIV><SPAN class=078041007-30042011><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=078041007-30042011><FONT face=Arial color=#0000ff size=2>I
suggest you move the #defines inside the union declaration to somewhere
before the union declaration. It'll double up the ifdef's but make the code
so much more readable.</FONT></SPAN></DIV>
<DIV><SPAN class=078041007-30042011><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=078041007-30042011><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV></DIV>
<DIV><FONT face=Tahoma size=2>-----Message
d'origine-----<BR><B>De :</B> fpc-pascal-bounces@lists.freepascal.org
[mailto:fpc-pascal-bounces@lists.freepascal.org] <B>De la part de</B>
ik<BR><B>Envoyé :</B> vendredi 29 avril 2011 22:15<BR><B>À :</B>
FPC-Pascal users discussions<BR><B>Objet :</B> [fpc-pascal] How to
translate this union ?<BR><BR></DIV></FONT>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV dir=ltr>Hello list,<BR><BR>I'm trying to translate the <A
href="https://github.com/ik5/sofia-sip/blob/master/src/lib/sui.inc#L199">following
union</A> to Pascal, but I do not understand it, and so does h2pas.<BR>How
to translate it ?<BR><BR>Thanks,<BR><BR>Ido<BR><BR><BR clear=all>
<DIV dir=ltr>LINESIP - Opening the source for communication<BR><A
href="http://www.linesip.com"
target=_blank>http://www.linesip.com</A><BR><A
href="http://www.linesip.co.il"
target=_blank>http://www.linesip.co.il</A><BR><BR></DIV><BR></DIV></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>