Program Listing for File endianness.hpp

Return to documentation for file (/tmp/ws/src/ecl_lite/ecl_config/include/ecl/config/endianness.hpp)

/*****************************************************************************
** Ifdefs
*****************************************************************************/

#ifndef ECL_CONFIG_ENDIANNESS_HPP_
#define ECL_CONFIG_ENDIANNESS_HPP_

/*****************************************************************************
** Includes
*****************************************************************************/

#include "portable_types.hpp"

/*****************************************************************************
** Namespaces
*****************************************************************************/

namespace ecl {
    inline bool is_big_endian() {
        union {
            uint32 i;
            char c[4];
        } bint = {0x01020304};

        return bint.c[0] == 1;
    }

} // namespace ecl

#endif /* ECL_CONFIG_ENDIANNESS_HPP_ */