9

I'm compiling in VS 2010 with boost 1_53. I'm also using boost's threads.

during compilation i'm getting bunch of errors like this

c:\program files (x86)\microsoft visual studio 10.0\vc\include\ctime(18): error C2039: 'clock_t' : is not a member of '`global namespace''

all errors are about ctime and c_time.hpp.

i've searched around for the solution but without success.

can anyone, please, help?

here some part of code.

#define BOOST_THREAD_USE_DLL 

#include <boost/optional.hpp>
#include <boost/thread.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
Nem
  • 336
  • 3
  • 8
  • 22
  • 1
    If you are including `` as ``, you may be inadvertently including a completely different file depending on your includes path. – user657267 May 28 '14 at 09:00
  • What is the first error you get? The rest might just be collateral damage. – rubenvb May 28 '14 at 09:00
  • Here is the first error: c:\program files (x86)\microsoft visual studio 10.0\vc\include\ctime(18): error C2039: 'clock_t' : is not a member of '`global namespace'' – Nem May 28 '14 at 09:02
  • May be i need to add some preprocessor rules? – Nem May 28 '14 at 09:03
  • did you link boost? What's your make command? – Theolodis May 28 '14 at 09:06
  • 2
    @mikners Can you post a [SSCCE](http://sscce.org/)? – rubenvb May 28 '14 at 09:07
  • @rubenvb I guess [this](http://www.cplusplus.com/forum/windows/88210/) could be the SSCCE. He is probably missing the link to boost as thread is not header only. – Theolodis May 28 '14 at 09:09
  • possible duplicate of [How to include boost::thread in your C++ project?](http://stackoverflow.com/questions/2174519/how-to-include-boostthread-in-your-c-project) – Theolodis May 28 '14 at 09:10
  • 1
    @Theolodis: I doubt that is relevant. Linker errors <-> compiler errors. – rubenvb May 28 '14 at 09:10
  • @rubenvb you are right... the first link contains the same problem though, with additional sample. – Theolodis May 28 '14 at 09:12
  • let me check the link. additional include directories include boost. – Nem May 28 '14 at 09:14
  • also, i jsut want to mention, that some says that this error can be the result of namespace problem (not closing brackets) – Nem May 28 '14 at 09:17
  • i've installed boost with the installer downloaded from boost's site. – Nem May 28 '14 at 09:18
  • we need a short example which reproduces the problem. voting to close. – Karoly Horvath May 28 '14 at 09:42
  • Thank you all for the replies. I've learned a lot from the posted links. The solution was quite easy and somehow funny. Project has many dependencies from another projects. and additional directories include this : ../../Project;../../Project/SubFolder. after removing this all errors're gone. Thanks again! – Nem May 28 '14 at 09:48
  • Not sure about VS2010, but if it lets you specify system include path separately to user include path - don't pollute system include path with junk from your projects; do all of that in the user include path. – M.M Jun 04 '14 at 00:29

1 Answers1

19

Something, somewhere in your codebase is including a different "time.h". I just discovered this migrating code from Linux to Windows - Because windows is case insensitive, a local "Time.h" (note the capital) was included as "time.h", causing the error that you see.

According to someone's post, FFMPEG can cause this problem via this precise mechanism.

Please look through your codebase and/or libraries for a "time.h" to see if this is happening. Otherwise, an alternate option is to output the fully pre-processed source to see what is actually being compiled in the offending file.

Damien
  • 785
  • 3
  • 8
  • 18
  • 1
    This was exactly my issue - created my own header named "Time.h" and started experiencing the problem. – geomnerd Mar 30 '16 at 14:09