Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphite Fails to Compile in recent Electronite version 22 - arithmetic between different enumeration types ('status_t' and 'graphite2::errors') is deprecated #78

Closed
PhotoNomad0 opened this issue Dec 6, 2022 · 0 comments
Assignees
Labels

Comments

@PhotoNomad0
Copy link

Electronite is a fork of Electron that adds Graphite support. And starting with Electron v22.0.0 (https://github.com/unfoldingWord/electronite/tree/electronite-v22.0.0-beta), graphite fails to compile in the Electron Build environment. There are three lines in:

../../third_party/graphite/graphite2/src/Pass.cpp:197:92: error: arithmetic between different enumeration types ('status_t' and 'graphite2::errors') is deprecated [-Werror,-Wdeprecated-enum-enum-conversion]

It appears that starting in Electron v22, the build environment has changed so that this has been escalated from a build warning to an error.

Found this article addressing the issue: https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5054?view=msvc-170

Created a patch to handle this (as well as the std::iterator deprecated error mentioned in #76):

diff --git a/src/GlyphCache.cpp b/src/GlyphCache.cpp
index 282bdc18..336de3f1 100644
--- a/src/GlyphCache.cpp
+++ b/src/GlyphCache.cpp
@@ -44,12 +44,18 @@ namespace
     // variable length structures.
 
     template<typename W>
-    class _glat_iterator : public std::iterator<std::input_iterator_tag, std::pair<sparse::key_type, sparse::mapped_type> >
+    class _glat_iterator
     {
         unsigned short  key() const             { return uint16(be::peek<W>(_e) + _n); }
         unsigned int    run() const             { return be::peek<W>(_e+sizeof(W)); }
         void            advance_entry()         { _n = 0; _e = _v; be::skip<W>(_v,2); }
     public:
+        using iterator_category = std::input_iterator_tag;
+        using value_type = std::pair<sparse::key_type, sparse::mapped_type>;
+        using difference_type = std::pair<sparse::key_type, sparse::mapped_type>;
+        using pointer = std::pair<sparse::key_type, sparse::mapped_type>*;
+        using reference = std::pair<sparse::key_type, sparse::mapped_type>&;
+        
         _glat_iterator(const void * glat=0) : _e(reinterpret_cast<const byte *>(glat)), _v(_e+2*sizeof(W)), _n(0) {}
 
         _glat_iterator<W> & operator ++ () {
diff --git a/src/Pass.cpp b/src/Pass.cpp
index db31c22d..c744bcbc 100644
--- a/src/Pass.cpp
+++ b/src/Pass.cpp
@@ -194,7 +194,7 @@ bool Pass::readPass(const byte * const pass_start, size_t pass_length, size_t su
         m_cPConstraint = vm::Machine::Code(true, pcCode, pcCode + pass_constraint_len,
                                   precontext[0], be::peek<uint16>(sort_keys), *m_silf, face, PASS_TYPE_UNKNOWN);
         if (e.test(!m_cPConstraint, E_OUTOFMEM)
-                || e.test(m_cPConstraint.status() != Code::loaded, m_cPConstraint.status() + E_CODEFAILURE))
+                || e.test(m_cPConstraint.status() != Code::loaded, m_cPConstraint.status() + static_cast<int> (E_CODEFAILURE)))
             return face.error(e);
         face.error_context(face.error_context() - 1);
     }
@@ -266,8 +266,8 @@ bool Pass::readRules(const byte * rule_map, const size_t num_entries,
         r->constraint = new (m_codes+n*2-1) vm::Machine::Code(true,  rc_begin, rc_end, r->preContext, r->sort, *m_silf, face, pt, &prog_pool_free);
 
         if (e.test(!r->action || !r->constraint, E_OUTOFMEM)
-                || e.test(r->action->status() != Code::loaded, r->action->status() + E_CODEFAILURE)
-                || e.test(r->constraint->status() != Code::loaded, r->constraint->status() + E_CODEFAILURE)
+                || e.test(r->action->status() != Code::loaded, r->action->status() + static_cast<int> (E_CODEFAILURE))
+                || e.test(r->constraint->status() != Code::loaded, r->constraint->status() + static_cast<int> (E_CODEFAILURE))
                 || e.test(!r->constraint->immutable(), E_MUTABLECCODE))
             return face.error(e);
     }
@tim-eves tim-eves self-assigned this Dec 13, 2022
@tim-eves tim-eves added the bug label Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants