foamEndianFwd.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Description
27  Define WM_BIG_ENDIAN or WM_LITTLE_ENDIAN
28  and forward declare Foam::endian class.
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #ifndef Foam_foamEndianFwd_H
33 #define Foam_foamEndianFwd_H
34 
35 #include <cstdint>
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 #ifdef __BYTE_ORDER__
40  // Clang, Gcc, Icc, Pgi
41  #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
42  #define WM_LITTLE_ENDIAN
43  #elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
44  #define WM_BIG_ENDIAN
45  #else
46  #error "__BYTE_ORDER__ is not BIG or LITTLE endian"
47  #endif
48 #endif
49 
50 // Could downgrade to a warning, but then user always needs runtime check.
51 #if !defined(WM_BIG_ENDIAN) && !defined(WM_LITTLE_ENDIAN)
52  #error "Cannot determine BIG or LITTLE endian."
53  #error "Please add to compilation options"
54 #endif
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace Foam
59 {
60 
61 class endian;
62 
63 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
64 
65 } // End namespace Foam
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 #endif
70 
71 // ************************************************************************* //
Namespace for OpenFOAM.