diff --git a/src/call.cpp b/src/call.cpp
index c219a6c4c59c44216539b623c38f724b5fdd699f..a031eb9c1558f2147e63939ae5a082f151322b55 100644
--- a/src/call.cpp
+++ b/src/call.cpp
@@ -487,7 +487,7 @@ const QString Call::toHumanStateName(const Call::State cur)
          break;
       case Call::State::CONFERENCE_HOLD:
          return tr( "Conference (hold)" );
-      case Call::State::COUNT:
+      case Call::State::__COUNT:
          return tr( "ERROR"             );
       default:
          return QString::number(static_cast<int>(cur));
@@ -780,7 +780,7 @@ Call::State Call::stateChanged(const QString& newStateName)
    Call::State previousState = m_CurrentState;
    if (!m_isConference) {
       Call::DaemonState dcs = toDaemonCallState(newStateName);
-      if (dcs == Call::DaemonState::COUNT || m_CurrentState == Call::State::COUNT) {
+      if (dcs == Call::DaemonState::__COUNT || m_CurrentState == Call::State::__COUNT) {
          qDebug() << "Error: Invalid state change";
          return Call::State::FAILURE;
       }
@@ -918,7 +918,7 @@ Call::State Call::performAction(Call::Action action)
 ///Change the state
 void Call::changeCurrentState(Call::State newState)
 {
-   if (newState == Call::State::COUNT) {
+   if (newState == Call::State::__COUNT) {
       qDebug() << "Error: Call reach invalid state";
       m_CurrentState = Call::State::ERROR;
       throw newState;
@@ -1231,7 +1231,7 @@ void Call::warning()
    switch (m_CurrentState) {
       case Call::State::FAILURE        :
       case Call::State::ERROR          :
-      case Call::State::COUNT          :
+      case Call::State::__COUNT          :
          //If not stopped, then the counter will keep going
          //Getting here indicate something wrong happened
          //It can be normal, aka, an invalid URI such as '><'
@@ -1283,7 +1283,7 @@ void Call::appendText(const QString& str)
    case Call::State::ERROR:
    case Call::State::CONFERENCE:
    case Call::State::CONFERENCE_HOLD:
-   case Call::State::COUNT:
+   case Call::State::__COUNT:
    default:
       qDebug() << "Backspace on call not editable. Doing nothing.";
       return;
@@ -1325,7 +1325,7 @@ void Call::backspaceItemText()
       case Call::State::ERROR:
       case Call::State::CONFERENCE:
       case Call::State::CONFERENCE_HOLD:
-      case Call::State::COUNT:
+      case Call::State::__COUNT:
       default                          :
          qDebug() << "Backspace on call not editable. Doing nothing.";
          return;
@@ -1369,7 +1369,7 @@ void Call::reset()
       case Call::State::ERROR            :
       case Call::State::CONFERENCE       :
       case Call::State::CONFERENCE_HOLD  :
-      case Call::State::COUNT:
+      case Call::State::__COUNT:
       default                            :
          qDebug() << "Cannot reset" << m_CurrentState << "calls";
          return;
diff --git a/src/call.h b/src/call.h
index 089187d714117017f2fd23f54d9a1da610e51326..c047efecf8fcde926f20521e552244a3ecd2a51a 100644
--- a/src/call.h
+++ b/src/call.h
@@ -137,7 +137,7 @@ public:
       ERROR           = 10,/** This state should never be reached */
       CONFERENCE      = 11,/** This call is the current conference*/
       CONFERENCE_HOLD = 12,/** This call is a conference on hold*/
-      COUNT,
+      __COUNT,
    };
    Q_ENUMS(State)
 
@@ -245,7 +245,7 @@ public:
       HOLD    = 3, /** Call is on hold */
       HUNG_UP = 4, /** Call is over  */
       FAILURE = 5, /** Call has failed */
-      COUNT,
+      __COUNT,
    };
 
    /** @enum Call::Action
@@ -258,7 +258,7 @@ public:
       TRANSFER = 2, /** Put into or out of transfer mode*/
       HOLD     = 3, /** Hold or unhold the call */
       RECORD   = 4, /** Enable or disable recording */
-      COUNT,
+      __COUNT,
    };
 
    //Read only properties
diff --git a/src/keyexchangemodel.cpp b/src/keyexchangemodel.cpp
index 61b9db4c7a5a293661316609256bc274a67b0636..8989061e068348b404912d2f2326c5bd3bd7faef 100644
--- a/src/keyexchangemodel.cpp
+++ b/src/keyexchangemodel.cpp
@@ -49,7 +49,7 @@ QVariant KeyExchangeModel::data( const QModelIndex& index, int role) const
          case KeyExchangeModel::Type::SDES:
             return KeyExchangeModel::Name::SDES;
             break;
-         case KeyExchangeModel::Type::COUNT:
+         case KeyExchangeModel::Type::__COUNT:
             break;
       };
    }
@@ -94,7 +94,7 @@ const char* KeyExchangeModel::toDaemonName(KeyExchangeModel::Type type)
       case KeyExchangeModel::Type::SDES:
          return KeyExchangeModel::DaemonName::SDES;
          break;
-      case KeyExchangeModel::Type::COUNT:
+      case KeyExchangeModel::Type::__COUNT:
          break;
    };
    return nullptr; //Cannot heppen
diff --git a/src/keyexchangemodel.h b/src/keyexchangemodel.h
index 99f57ac4f88ecba5bab99763d229c124c346b64a..93a75062973cc60e3469f0a7edf60110e437de42 100644
--- a/src/keyexchangemodel.h
+++ b/src/keyexchangemodel.h
@@ -37,7 +37,7 @@ public:
       ZRTP = 0,
       SDES = 1,
       NONE = 2,
-      COUNT,
+      __COUNT,
    };
 
    ///@enum Options Every Key exchange options
@@ -47,7 +47,7 @@ public:
       NOT_SUPP_WARNING = 2,
       HELLO_HASH       = 3,
       DISPLAY_SAS_ONCE = 4,
-      COUNT,
+      __COUNT,
    };
 
    class Name {
diff --git a/src/securityvalidationmodel.cpp b/src/securityvalidationmodel.cpp
index 8bb66a51283b650de3a0443d95d5e98673d5c638..d61e063a10dccce1c4ec4f3007e30fae59e265fa 100644
--- a/src/securityvalidationmodel.cpp
+++ b/src/securityvalidationmodel.cpp
@@ -21,7 +21,7 @@
 
 #include <QtAlgorithms>
 
-const QString SecurityValidationModel::messages[static_cast<const int>(SecurityFlaw::COUNT)] = {
+const QString SecurityValidationModel::messages[enum_class_size<SecurityFlaw>()] = {
    QObject::tr("Your communication negotiation is secured, but not the media stream, please enable ZRTP or SDES"),
    QObject::tr("TLS is disabled, the negotiation wont be encrypted. Your communication will be vulnerable to "
    "snooping"),
diff --git a/src/securityvalidationmodel.h b/src/securityvalidationmodel.h
index 33dcfaa4fb097439ab5585f0027c9acb2650d1f4..7f4d9d4b27df1e1a2491ec4e0da92ea9ffeb9960 100644
--- a/src/securityvalidationmodel.h
+++ b/src/securityvalidationmodel.h
@@ -90,7 +90,7 @@ public:
       REQUIRE_CERTIFICATE_DISABLED   ,
       MISSING_CERTIFICATE            ,
       MISSING_AUTHORITY              ,
-      COUNT
+      __COUNT
    };
 
    ///Role for the model
@@ -99,7 +99,7 @@ public:
    };
 
    ///Messages to show to the end user
-   static const QString messages[static_cast<const int>(SecurityFlaw::COUNT)];
+   static const QString messages[enum_class_size<SecurityFlaw>()];
 
    //Constructor
    SecurityValidationModel(Account* account);
diff --git a/src/typedefs.h b/src/typedefs.h
index d3fb6b1888f75d304fe3278c7263a2a5509b9ad9..fab17a0a2f97abcd4e54a61b504ac0d932c97145 100644
--- a/src/typedefs.h
+++ b/src/typedefs.h
@@ -34,10 +34,10 @@ template<class T, class E>
 struct TypedStateMachine
 {
     // no ctor/dtor and one public member variable for easy initialization
-    T _data[size_t(E::COUNT)];
+    T _data[size_t(E::__COUNT)];
 
     T& operator[](E v) {
-      if (size_t(v) >= size_t(E::COUNT)) {
+      if (size_t(v) >= size_t(E::__COUNT)) {
          qDebug() << "State Machine Out of Bound" << size_t(v);
          throw v;
       }
@@ -45,7 +45,7 @@ struct TypedStateMachine
     }
 
     const T& operator[](E v) const {
-      if (size_t(v) >= size_t(E::COUNT)) {
+      if (size_t(v) >= size_t(E::__COUNT)) {
          qDebug() << "State Machine Out of Bound" << size_t(v);
          throw v;
       }
@@ -57,10 +57,19 @@ struct TypedStateMachine
     }
 
     T *end() {
-      return _data + size_t(E::COUNT);
+      return _data + size_t(E::__COUNT);
     }
 };
 
+/**
+ * This function add a safe way to get an enum class size
+ * @note it cannot be "const" due to some compiler issues
+ * @note it cannot be unsigned to avoid some compiler warnings
+ */
+template<typename A> constexpr int enum_class_size() {
+   return static_cast<int>(A::__COUNT);
+}
+
 #define LIB_EXPORT Q_DECL_EXPORT
 #define LIB_IMPORT Q_DECL_IMPORT
 
diff --git a/src/useractionmodel.cpp b/src/useractionmodel.cpp
index a679c1e113bd385dd0482a34a6c6cb14ea83ec5f..3724a5fb5ef174623238ef5dc7f92cf53b8cce12 100644
--- a/src/useractionmodel.cpp
+++ b/src/useractionmodel.cpp
@@ -87,7 +87,7 @@ void UserActionModel::slotStateChanged()
 uint UserActionModel::relativeIndex( UserActionModel::Action action ) const
 {
    int i(0),ret(0);
-   while (i != static_cast<int>(action) && i < static_cast<int>(UserActionModel::Action::COUNT)) {
+   while (i != static_cast<int>(action) && i < enum_class_size<UserActionModel::Action>()) {
       ret += isActionEnabled(static_cast<UserActionModel::Action>(i))?1:0;
       i++;
    }
@@ -97,7 +97,7 @@ uint UserActionModel::relativeIndex( UserActionModel::Action action ) const
 uint UserActionModel::enabledCount( ) const
 {
    uint ret =0;
-   for (int i=0;i< static_cast<int>(UserActionModel::Action::COUNT); i++)
+   for (int i=0;i< enum_class_size<UserActionModel::Action>(); i++)
       ret += isActionEnabled(static_cast<UserActionModel::Action>(i))?1:0;
    return ret;
 }
diff --git a/src/useractionmodel.h b/src/useractionmodel.h
index fe5aae77e4cc923b501b4076631f067b74d93172..781143124d0ad5ca1a640707d57267460ab5ae5f 100644
--- a/src/useractionmodel.h
+++ b/src/useractionmodel.h
@@ -53,7 +53,7 @@ public:
       REFUSE   = 6,
       ACCEPT   = 7,
       HANGUP   = 8,
-      COUNT,
+      __COUNT,
    };
    Q_ENUMS(Action)