Use enum instead of "static const" in class scope
Technically, static const needs an out-of-class definition. Eg:
CXXLD libharfbuzz-subset.la
Undefined symbols for architecture x86_64:
"OT::FeatureVariationRecord::min_size", referenced from:
bool OT::GSUBGPOS::subset<OT::PosLookup>(hb_subset_context_t*) constin libharfbuzz_subset_la-hb-subset.o
bool OT::GSUBGPOS::subset<OT::SubstLookup>(hb_subset_context_t*) constin libharfbuzz_subset_la-hb-subset.o
"OT::Record<OT::LangSys>::min_size", referenced from:
OT::Script::subset(hb_subset_context_t*) constin libharfbuzz_subset_la-hb-subset.o
"OT::IntType<unsigned short, 2u>::min_size", referenced from:
OT::Script::subset(hb_subset_context_t*) constin libharfbuzz_subset_la-hb-subset.o
OT::RecordListOf<OT::Feature>::subset(hb_subset_context_t*) const in libharfbuzz_subset_la-hb-subset.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[4]: *** [libharfbuzz-subset.la] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Exited with code 2
diff --git a/src/hb-buffer.hh b/src/hb-buffer.hh
index 3e38fe1..bcaf066 100644
--- a/src/hb-buffer.hh
+++ b/src/hb-buffer.hh
@@ -119,7 +119,7 @@
/* Text before / after the main buffer contents.
* Always in Unicode, and ordered outward.
* Index 0 is for "pre-context", 1 for "post-context". */
- static const unsigned int CONTEXT_LENGTH = 5;
+ enum { CONTEXT_LENGTH = 5 };
hb_codepoint_t context[2][CONTEXT_LENGTH];
unsigned int context_len[2];
diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh
index 6899416..62f4907 100644
--- a/src/hb-machinery.hh
+++ b/src/hb-machinery.hh
@@ -99,8 +99,8 @@
#define DEFINE_SIZE_STATIC(size) \
DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size)); \
- static const unsigned int static_size = (size); \
- static const unsigned int min_size = (size); \
+ enum { static_size = (size) }; \
+ enum { min_size = (size) }; \
inline unsigned int get_size (void) const { return (size); }
#define DEFINE_SIZE_UNION(size, _member) \
@@ -114,7 +114,7 @@
#define DEFINE_SIZE_ARRAY(size, array) \
DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size) + VAR * sizeof (array[0])); \
DEFINE_COMPILES_ASSERTION ((void) array[0].static_size) \
- static const unsigned int min_size = (size); \
+ enum { min_size = (size) }; \
#define DEFINE_SIZE_ARRAY_SIZED(size, array) \
DEFINE_SIZE_ARRAY(size, array); \
@@ -133,7 +133,7 @@
template <typename Context, typename Return, unsigned int MaxDebugDepth>
struct hb_dispatch_context_t
{
- static const unsigned int max_debug_depth = MaxDebugDepth;
+ enum { max_debug_depth = MaxDebugDepth };
typedef Return return_t;
template <typename T, typename F>
inline bool may_dispatch (const T *obj, const F *format) { return true; }
diff --git a/src/hb-open-file.hh b/src/hb-open-file.hh
index 847f9b0..d3b7486 100644
--- a/src/hb-open-file.hh
+++ b/src/hb-open-file.hh
@@ -115,7 +115,7 @@
* table list. */
int i = tables.len < 64 ? tables.lsearch (t) : tables.bsearch (t);
if (table_index)
- *table_index = i == -1 ? Index::NOT_FOUND_INDEX : (unsigned int) i;
+ *table_index = i == -1 ? (unsigned) Index::NOT_FOUND_INDEX : (unsigned) i;
return i != -1;
}
inline const TableRecord& get_table_by_tag (hb_tag_t tag) const
diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh
index 29afa94..ef18163 100644
--- a/src/hb-open-type.hh
+++ b/src/hb-open-type.hh
@@ -150,7 +150,7 @@
/* Script/language-system/feature index */
struct Index : HBUINT16 {
- static const unsigned int NOT_FOUND_INDEX = 0xFFFFu;
+ enum { NOT_FOUND_INDEX = 0xFFFFu };
};
DECLARE_NULL_NAMESPACE_BYTES (OT, Index);
diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh
index ca3d7d5..dd65f33 100644
--- a/src/hb-ot-layout-common.hh
+++ b/src/hb-ot-layout-common.hh
@@ -1743,7 +1743,7 @@
struct FeatureVariations
{
- static const unsigned int NOT_FOUND_INDEX = 0xFFFFFFFFu;
+ enum { NOT_FOUND_INDEX = 0xFFFFFFFFu };
inline bool find_index (const int *coords, unsigned int coord_len,
unsigned int *index) const
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 3450789..a1220f4 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -1068,7 +1068,7 @@
struct GSUBProxy
{
- static const unsigned int table_index = 0;
+ enum { table_index = 0 };
static const bool inplace = false;
typedef OT::SubstLookup Lookup;
@@ -1082,7 +1082,7 @@
struct GPOSProxy
{
- static const unsigned int table_index = 1;
+ enum { table_index = 1 };
static const bool inplace = true;
typedef OT::PosLookup Lookup;
diff --git a/src/hb-set-digest.hh b/src/hb-set-digest.hh
index 4cd7c3f..0f9329f 100644
--- a/src/hb-set-digest.hh
+++ b/src/hb-set-digest.hh
@@ -50,8 +50,8 @@
{
ASSERT_POD ();
- static const unsigned int mask_bytes = sizeof (mask_t);
- static const unsigned int mask_bits = sizeof (mask_t) * 8;
+ enum { mask_bytes = sizeof (mask_t) };
+ enum { mask_bits = sizeof (mask_t) * 8 };
static const unsigned int num_bits = 0
+ (mask_bytes >= 1 ? 3 : 0)
+ (mask_bytes >= 2 ? 1 : 0)
diff --git a/src/hb-set.hh b/src/hb-set.hh
index a179ad1..353403e 100644
--- a/src/hb-set.hh
+++ b/src/hb-set.hh
@@ -157,7 +157,7 @@
}
typedef unsigned long long elt_t;
- static const unsigned int PAGE_BITS = 512;
+ enum { PAGE_BITS = 512 };
static_assert ((PAGE_BITS & ((PAGE_BITS) - 1)) == 0, "");
static inline unsigned int elt_get_min (const elt_t &elt) { return hb_ctz (elt); }
@@ -165,11 +165,11 @@
typedef hb_vector_size_t<elt_t, PAGE_BITS / 8> vector_t;
- static const unsigned int ELT_BITS = sizeof (elt_t) * 8;
- static const unsigned int ELT_MASK = ELT_BITS - 1;
- static const unsigned int BITS = sizeof (vector_t) * 8;
- static const unsigned int MASK = BITS - 1;
- static_assert (PAGE_BITS == BITS, "");
+ enum { ELT_BITS = sizeof (elt_t) * 8 };
+ enum { ELT_MASK = ELT_BITS - 1 };
+ enum { BITS = sizeof (vector_t) * 8 };
+ enum { MASK = BITS - 1 };
+ static_assert ((unsigned) PAGE_BITS == (unsigned) BITS, "");
elt_t &elt (hb_codepoint_t g) { return v[(g & MASK) / ELT_BITS]; }
elt_t const &elt (hb_codepoint_t g) const { return v[(g & MASK) / ELT_BITS]; }