title: Using strptime under cygwin64 on Windows 8 in CodeBlocks
body: <p>I am trying to compile some code originally written in linux on my Windows machine. I have Cygwin installed and setup for use within CodeBlocks, and it works mostly. All except a call to strptime, which greets me with "error: 'strptime' was not delcared in this scope." I've been googling for a while now to no avail, please could someone explain what might be wrong? I've tried including time.h but no luck. </p>
  
  <pre><code>#ifndef _XOPEN_SOURCE
  #define _XOPEN_SOURCE
  #endif
  
  #include &lt;ctime&gt;
  #include &lt;cstring&gt;
  
  class Date {
  private:
    struct tm _tm;
    string strform;
  
    static void set_zero(struct tm &amp;_tm) {
      memset(&amp;_tm, '\0', sizeof(struct tm));
      //    _tm.hour = 0;
    }
  
    time_t make_time() {
      return mktime(&amp;_tm);
    }
  
  public:
    Date() {
      time_t current = time(NULL);
      _tm = *gmtime(&amp;current);
      char buffer[1024];
      strftime(buffer, 1024, "%b %e %Y", &amp;_tm);
      strform = buffer;
    }
  
    Date(time_t current) {
      _tm = *gmtime(&amp;current);
      char buffer[1024];
      strftime(buffer, 1024, "%b %e %Y", &amp;_tm);
      strform = buffer;
    }
  
    Date(string _strform) {
      strform = _strform;
      set_zero(_tm);
      char *result = strptime(strform.c_str(), "%b %e %Y", &amp;_tm);
      assert(result);
      char buffer[1024];
      strftime(buffer, 1024, "%b %e %Y", &amp;_tm);
      strform = buffer;
      //cout &lt;&lt; "strform = " &lt;&lt; strform &lt;&lt; endl;
      //    cout &lt;&lt; "length = " &lt;&lt; result - strform.c_str() &lt;&lt; endl;
      //    cout &lt;&lt; "day = " &lt;&lt; _tm.tm_mday &lt;&lt; endl;
      //    cout &lt;&lt; "month = " &lt;&lt; _tm.tm_mon &lt;&lt; endl;
      //    cout &lt;&lt; "year = " &lt;&lt; _tm.tm_year &lt;&lt; endl;
      //    char buffer[1024];
      //    strftime(buffer, 1024, "%b %e %Y   %H:%M:%S", &amp;_tm);
      //    cout &lt;&lt; "buffer = " &lt;&lt; buffer &lt;&lt; endl;
    }
  
    Date operator-(int days) {
      return Date(make_time() - days*86400 );
    }
  
    time_t operator-(Date &amp;other) {
      return (make_time() - other.make_time())/86400.0;
    }
  
    bool operator&lt;=(Date &amp;other) {
      return make_time() &lt;= other.make_time();
    }
  
    bool operator&lt;(Date &amp;other) {
      return make_time() &lt; other.make_time();
    }
  
    bool operator&gt;=(Date &amp;other) {
      return make_time() &gt;= other.make_time();
    }
  
    time_t to_seconds() {
      return make_time();
    }
  
    friend ostream &amp;operator&lt;&lt; (ostream &amp;out, const Date &amp;d) {
      return out &lt;&lt; d.strform;
    }
  
    static Date today() {
      return Date();
    }
  
    string to_string() const {
      return strform;
    }
  
    const char *to_cstring() const {
      return strform.c_str();
    }
  };
  </code></pre>