ecl_endian_flip.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2011 Equinor ASA, Norway.
3
4 The file 'ecl_endian_flip.h' is part of ERT - Ensemble based Reservoir Tool.
5
6 ERT is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 ERT is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.
14
15 See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
16 for more details.
17*/
18
19#ifndef ERT_ECL_ENDIAN_FLIP_H
20#define ERT_ECL_ENDIAN_FLIP_H
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25#include <stdbool.h>
26
38#define ECLIPSE_BYTE_ORDER __BIG_ENDIAN // Alternatively: __LITTLE_ENDIAN
39
40#ifdef BYTE_ORDER
41 #if BYTE_ORDER == ECLIPSE_BYTE_ORDER
42 #define ECL_ENDIAN_FLIP false
43 #else
44 #define ECL_ENDIAN_FLIP true
45 #endif
46#else
47 #ifdef WIN32
48 #define ECL_ENDIAN_FLIP true // Unconditional byte flip on Windows.
49 #else
50 #error: The macro BYTE_ORDER is not defined?
51 #endif
52#endif
53
54#undef ECLIPSE_BYTE_ORDER
55
56
57#ifdef __cplusplus
58}
59#endif
60#endif