Skip to content

Commit 414bd0e

Browse files
committed
Merge pull request #133 from treeowl/minversionbase
Improve MIN_VERSION_base fall-back
2 parents fabde6b + 3dddb04 commit 414bd0e

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

include/containers.h

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,30 @@
5151
/*
5252
* We use cabal-generated MIN_VERSION_base to adapt to changes of base.
5353
* Nevertheless, as a convenience, we also allow compiling without cabal by
54-
* defining trivial MIN_VERSION_base if needed.
54+
* defining an approximate MIN_VERSION_base if needed. The alternative version
55+
* guesses the version of base using the version of GHC. This is usually
56+
* sufficiently accurate. However, it completely ignores minor version numbers,
57+
* and it makes the assumption that a pre-release version of GHC will ship with
58+
* base libraries with the same version numbers as the final release. This
59+
* assumption is violated in certain stages of GHC development, but in practice
60+
* this should very rarely matter, and will not affect any released version.
5561
*/
5662
#ifndef MIN_VERSION_base
57-
#define MIN_VERSION_base(major1,major2,minor) 0
63+
#if __GLASGOW_HASKELL__ >= 709
64+
#define MIN_VERSION_base(major1,major2,minor) (((major1)<4)||(((major1) == 4)&&((major2)<=8)))
65+
#elif __GLASGOW_HASKELL__ >= 707
66+
#define MIN_VERSION_base(major1,major2,minor) (((major1)<4)||(((major1) == 4)&&((major2)<=7)))
67+
#elif __GLASGOW_HASKELL__ >= 705
68+
#define MIN_VERSION_base(major1,major2,minor) (((major1)<4)||(((major1) == 4)&&((major2)<=6)))
69+
#elif __GLASGOW_HASKELL__ >= 703
70+
#define MIN_VERSION_base(major1,major2,minor) (((major1)<4)||(((major1) == 4)&&((major2)<=5)))
71+
#elif __GLASGOW_HASKELL__ >= 701
72+
#define MIN_VERSION_base(major1,major2,minor) (((major1)<4)||(((major1) == 4)&&((major2)<=4)))
73+
#elif __GLASGOW_HASKELL__ >= 700
74+
#define MIN_VERSION_base(major1,major2,minor) (((major1)<4)||(((major1) == 4)&&((major2)<=3)))
75+
#else
76+
#define MIN_VERSION_base(major1,major2,minor) (0)
5877
#endif
78+
#endif // MIN_VERSION_base was not defined
5979

60-
61-
#endif
80+
#endif // This file was already included

0 commit comments

Comments
 (0)