Search code examples
clinuxubuntuqnxqnx-neutrino

Equivalent of ENDIAN_BE16() function for Ubunu


What is the exact equivalent of the following function for Ubuntu?

http://www.qnx.com/developers/docs/6.4.1/neutrino/lib_ref/e/endian_be16.html


Solution

  • What you need is:

    #include <endian.h>
    
    result_in_host_endianness = be16toh(my_big_endian_number)
    

    See http://man7.org/linux/man-pages/man3/endian.3.html