Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-06

Endiannes & programmer's manual - missing compiler define?

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Reinier Olislagers

Had a look at the Programmer's Manual (April 2011, doc version 2.4) appendix G (compiler defines)

Saw
ENDIAN_LITTLE
ENDIAN_BIG

Did not see
FPC_LITTLE_ENDIAN
FPC_BIG_ENDIAN

Should that be added?

Also, I'm sure there must be functions to convert endianness - at least
network byte order (big endian) to host order.
I found e.g. Synapse synsock:
  function ntohs(netshort: word): word;
  function ntohl(netlong: longword): longword;
  function htons(hostshort: word): word;
  function htonl(hostlong: longword): longword;

Are there an equivalent RTL/FCL functions?

Thanks,
Reinier

Reply by email

Sven Barth
to Reinier Olislagers
Reinier Olislagers wrote 9 lines
Also, I'm sure there must be functions to convert endianness - at least network byte order (big endian) to host order. I found e.g. Synapse synsock: function ntohs(netshort: word): word; function ntohl(netlong: longword): longword; function htons(hostshort: word): word; function htonl(hostlong: longword): longword; Are there an equivalent RTL/FCL functions?

They are in FPC's sockets unit.

Regards,
Sven

Reply by email

Marco van de Voort
to Reinier Olislagers: Had a look at the Programmer's Manual (April 2011, doc version 2.4) appendix G (compiler…

In our previous episode, Reinier Olislagers said:

Show quoted text 10 lines
Also, I'm sure there must be functions to convert endianness - at least network byte order (big endian) to host order. I found e.g. Synapse synsock: function ntohs(netshort: word): word; function ntohl(netlong: longword): longword; function htons(hostshort: word): word; function htonl(hostlong: longword): longword; Are there an equivalent RTL/FCL functions?

Yes, but don't use them.

There are independent endian routines in system. Search for swapendian and BEtoN, NtoBE etc.

Do not abuse network routines for non network usage.

Reply by email

Reinier Olislagers
to Marco van de Voort
Marco van de Voort wrote
In our previous episode, Reinier Olislagers said: > > Also, I'm sure there must be functions to convert endianness - at least > network byte order (big endian) to host order.

<snip>

Show quoted text 6 lines
> Are there an equivalent RTL/FCL functions? Yes, but don't use them. There are independent endian routines in system. Search for swapendian and BEtoN, NtoBE etc.

Thanks.

Do not abuse network routines for non network usage.

I hear & obey ;)
Updated the wiki:
http://wiki.lazarus.freepascal.org/Writing_portable_code_regarding_the_processor_architecture#Changing_Endianness

Thanks,

Reinier

Reply by email