title: Boost compile error with C2039: time_t is not a member of std
body: <p>I have a problem when compile BOOST library using MSVC2015 64-bit on Windows10 64-bit machine.</p>
  
  <p><a href="https://i.stack.imgur.com/fxpd2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fxpd2.png" alt="enter image description here"></a></p>
  
  <p>I use QT creator as IDE and enable C++14 by using flag
  in .pro  </p>
  
  <p>QMAKE_CXXFLAGS += -std=c++14</p>
  
  <p>here is the part of error that happens in BOOST library: c_time.hpp</p>
  
  <pre><code>  //! requires a pointer to a user created std::tm struct
    inline
    static std::tm* localtime(const std::time_t* t, std::tm* result)
    {
      result = std::localtime(t);
      if (!result)
        boost::throw_exception(std::runtime_error("could not convert calendar time to local time"));
      return result;
    }
    //! requires a pointer to a user created std::tm struct
    inline
    static std::tm* gmtime(const std::time_t* t, std::tm* result)
    {
      result = std::gmtime(t);
      if (!result)
        boost::throw_exception(std::runtime_error("could not convert calendar time to UTC time"));
      return result;
    }
  </code></pre>
  
  <p>the compiler yelled that  std::time_t  time_t is not a part of std namespace
  also same problem as std::localtime and std::gmtime </p>
  
  <p>I also #include  <code>&lt;ctime&gt;  &lt;time.h&gt; &lt;cstdlib&gt;</code> in main before calling all boost libraries but it does not help.</p>
  
  <p>another thing that I found when i tried to trace back to ctime (std c++ file in C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ctime) here is the part of the code in ctime</p>
  
  <pre><code> #if _GLOBAL_USING &amp;&amp; !defined(RC_INVOKED)
  _STD_BEGIN
  using _CSTD clock_t; using _CSTD size_t;
  using _CSTD time_t; using _CSTD tm;
  using _CSTD asctime; using _CSTD clock; using _CSTD ctime;
  using _CSTD difftime; using _CSTD gmtime; using _CSTD localtime;
  using _CSTD mktime; using _CSTD strftime; using _CSTD time;
  _STD_END
   #endif /* _GLOBAL_USING */
  #endif /* _CTIME_ */code here
  </code></pre>
  
  <p>the error is clock_t: symbol cannot be used in a using declaration error</p>
  
  <p>or</p>
  
  <p>clock_t is not a member of global namespace</p>
  
  <p>I tried with different versions of BOOST library ( boost 1.64, boost 1.65, boost 1.66) The libraries I download from precompile BOOST binaries and install directly to my machine ( <a href="https://sourceforge.net/projects/boost/files/boost-binaries/" rel="nofollow noreferrer">https://sourceforge.net/projects/boost/files/boost-binaries/</a> )</p>
  
  <p>here is my pro file from QT creator using MSVC2015 as compiler</p>
  
  <pre><code>BOOST_PATH   = C:/local/boost_1_66_0
  INCLUDEPATH +=   $${BOOST_PATH}
  LIBS        += -L$${BOOST_PATH}/lib64-msvc-14.1
  LIBS        += -lboost_atomic-vc140-mt-1_66
  LIBS        += -lboost_chrono-vc140-mt-1_66
  ..........
  
  SOURCES += \
          main.cpp \
          mainwindow.cpp
  
  HEADERS += \
          mainwindow.h
  
  FORMS += \
          mainwindow.ui
  </code></pre>
  
  <p>here is what my main.cpp look like. This is a clean QT Application project. There is nothing in other files</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;cstdlib&gt;
  #include &lt;limits&gt;
  #include &lt;fstream&gt;
  #include &lt;vector&gt;
  #include "boost/filesystem.hpp"
  
  #include "mainwindow.h"
  #include &lt;QApplication&gt;
  int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
      MainWindow w;
      w.show();
  
      return a.exec();
  }
  </code></pre>
  
  <p>NOTE: I think the problem is MSVC compiler find function in a wrong namespace. for example  std::localtime() should find in std namespace but the compiler find this function "localtime" in c_time.hpp and it tries to match std::localtime to boost::localtime and give the error.</p>