cpp: Use #pragma once instead of #ifndef guards
[ghc.git] / libraries / base / include / CTypes.h
1 {- --------------------------------------------------------------------------
2 // Dirty CPP hackery for CTypes/CTypesISO
3 //
4 // (c) The FFI task force, 2000
5 // --------------------------------------------------------------------------
6 -}
7
8 #pragma once
9
10 {-
11 // As long as there is no automatic derivation of classes for newtypes we resort
12 // to extremely dirty cpp-hackery. :-P Some care has to be taken when the
13 // macros below are modified, otherwise the layout rule will bite you.
14 -}
15
16 -- // GHC can derive any class for a newtype, so we make use of that here...
17
18 #define ARITHMETIC_CLASSES Eq,Ord,Num,Enum,Storable,Real
19 #define INTEGRAL_CLASSES Bounded,Integral,Bits,FiniteBits
20 #define FLOATING_CLASSES Fractional,Floating,RealFrac,RealFloat
21 #define OPAQUE_CLASSES Eq,Ord,Storable
22
23 #define ARITHMETIC_TYPE(T,B) \
24 newtype T = T B deriving (ARITHMETIC_CLASSES) \
25 deriving newtype (Read, Show);
26
27 #define INTEGRAL_TYPE(T,B) \
28 newtype T = T B deriving (ARITHMETIC_CLASSES, INTEGRAL_CLASSES) \
29 deriving newtype (Read, Show);
30
31 #define INTEGRAL_TYPE_WITH_CTYPE(T,THE_CTYPE,B) \
32 newtype {-# CTYPE "THE_CTYPE" #-} T = T B \
33 deriving (ARITHMETIC_CLASSES, INTEGRAL_CLASSES) \
34 deriving newtype (Read, Show);
35
36 #define FLOATING_TYPE(T,B) \
37 newtype T = T B deriving (ARITHMETIC_CLASSES, FLOATING_CLASSES) \
38 deriving newtype (Read, Show);
39
40 #define FLOATING_TYPE_WITH_CTYPE(T,THE_CTYPE,B) \
41 newtype {-# CTYPE "THE_CTYPE" #-} T = T B \
42 deriving (ARITHMETIC_CLASSES, FLOATING_CLASSES) \
43 deriving newtype (Read, Show);
44
45 #define OPAQUE_TYPE_WITH_CTYPE(T,THE_CTYPE,B) \
46 newtype {-# CTYPE "THE_CTYPE" #-} T = T (B) \
47 deriving (OPAQUE_CLASSES) \
48 deriving newtype Show;