Download MetaTrader 5

enum incorrect branch in switch

To add comments, please log in or register
Paul
784
Paul  

I have a bug in my code in which a switch statement branches to the wrong case for a user-defined enum. 

Here's the code which reports the incorrect enum.  When m_LogLevel == LOG_VERBOSE (4), the function returns LOG_DEBUG.  But unfortunately when I try to distill the problem down to a small example piece of code, the problem goes away.

string CLog::LogLevelString()
  {
   switch(m_LogLevel)
     {
      case LOG_NONE: return("LOG_NONE"); // 0
      case LOG_PRINT: return("LOG_PRINT"); // 1
      case LOG_MAJOR: return("LOG_MAJOR"); // 2
      case LOG_DEBUG: return("LOG_DEBUG"); // 3
      case LOG_VERBOSE: return("LOG_VERBOSE"); // 4
      default: return("error: Unknown log level "+(string)m_LogLevel);
     }
  }

Has anyone else noticed behaviour like this? 

Paul 

http://paulsfxrandomwalk.blogspot.com/

Regularly emailing the status of an account
  • 2012.06.14
  • Paul
  • paulsfxrandomwalk.blogspot.com
Prompted by a query, I thought I'd post a useful little utility that I have used for ages which emails the status of the account every hour.  After lengthy deliberation I decided to call it .... EmailStatus.  With only a small modification it could be used to log the status to a file, and the time...
Paul
784
Paul  
phampton posted  :

 

I have a bug in my code in which a switch statement branches to the wrong case for a user-defined enum. 

Here's the code which reports the incorrect enum.  When m_LogLevel == LOG_VERBOSE (4), the function returns LOG_DEBUG.  But unfortunately when I try to distill the problem down to a small example piece of code, the problem goes away.

Has anyone else noticed behaviour like this? 

Paul 

http://paulsfxrandomwalk.blogspot.com/

 

forget it, I found a bug in my code :)
To add comments, please log in or register