Using strptime under cygwin64 on Windows 8 in CodeBlocks

前端 未结 3 1329
隐瞒了意图╮
隐瞒了意图╮ 2021-01-21 10:53

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

相关标签:
3条回答
  • 2021-01-21 10:58

    See this answer on XOPEN_SOURCE. I had some luck getting strptime to compile by adding add_definitions(-D_XOPEN_SOURCE=700) to my CMakeLists.txt. That ended letting strptime be found by the compiler, by turning features on in the header.

    0 讨论(0)
  • 2021-01-21 11:02

    This only happens in C++11 and above. It looks like __STRICT_ANSI__ is being set and strptime() is not defined under that. A workaround is to undef __STRICT_ANSI__ as follows.

    #ifdef __CYGWIN__
    #undef __STRICT_ANSI__
    #endif
    
    0 讨论(0)
  • 2021-01-21 11:20

    This error message means that function is not declared at the point it is found. It looks like strptime() is declared in the time.h file in Cygwin (at least in v1.7.25) so simply add:

     #include <time.h>
    

    to your source file. Note that strptime() is not a standard C function.

    0 讨论(0)
提交回复
热议问题