Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building in Cygwin fails due to undeclared strptime in time.h #3178

Closed
thesmurph opened this issue Nov 13, 2022 · 1 comment
Closed

Building in Cygwin fails due to undeclared strptime in time.h #3178

thesmurph opened this issue Nov 13, 2022 · 1 comment

Comments

@thesmurph
Copy link
Contributor

Building in Cygwin fails due to undeclared strptime in time.h. This function is not available when __GNU_VISIBLE is not defined. The strptime() function is defined in the X/Open Portability Guide Issue 4 ("XPG4"). Ultimately to enable strptime you can either define _GNU_SOURCE or set _XOPEN_VERSION to 4/500/600/700. I was able to build fmt after adding "add_definitions(-D_XOPEN_SOURCE=700)" to CMakeLists.txt.

CMake version: 3.23.2
The CXX compiler identification is GNU 11.3.0
commit d2e89c8

Error Message
[ 68%] Building CXX object test/CMakeFiles/scan-test.dir/scan-test.cc.o
/home/Matt/fmt/test/scan-test.cc: In instantiation of ‘typename ScanContext::iterator fmt::v9::scanner::scan(tm&, ScanContext&) [with ScanContext = fmt::v9::scan_context; typename ScanContext::iterator = const char*]’:
/home/Matt/fmt/test/scan.h:111:26: required from ‘static void fmt::v9::detail::scan_arg::scan_custom_arg(void*, fmt::v9::scan_parse_context&, fmt::v9::scan_context&) [with T = tm]’
/home/Matt/fmt/test/scan.h:102:17: required from ‘fmt::v9::detail::scan_arg::scan_arg(T&) [with T = tm]’
/home/Matt/fmt/test/scan.h:231:20: required from ‘std::array<fmt::v9::detail::scan_arg, sizeof... (Args)> fmt::v9::make_scan_args(Args& ...) [with Args = {tm}]’
/home/Matt/fmt/test/scan.h:244:49: required from ‘const char* fmt::v9::scan(fmt::v9::string_view, fmt::v9::string_view, Args& ...) [with Args = {tm}; fmt::v9::basic_string_view::iterator = const char*; fmt::v9::string_view = fmt::v9::basic_string_view]’
/home/Matt/fmt/test/scan-test.cc:96:12: required from here
/home/Matt/fmt/test/scan-test.cc:86:27: error: ‘strptime’ was not declared in this scope; did you mean ‘strftime’?
86 | auto result = strptime(ctx.begin(), format.c_str(), &t);
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| strftime
make[2]: *** [test/CMakeFiles/scan-test.dir/build.make:76: test/CMakeFiles/scan-test.dir/scan-test.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:590: test/CMakeFiles/scan-test.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

/usr/include/time.h
#if __GNU_VISIBLE
char *strptime_l (const char *__restrict, const char *__restrict,
struct tm *__restrict, locale_t);
#endif

cygdrive/c/cygwin64/usr/include/sys/features.h
#ifdef _GNU_SOURCE
#define __GNU_VISIBLE 1
#else
#define __GNU_VISIBLE 0
#endif

@vitaut
Copy link
Contributor

vitaut commented Nov 13, 2022

strptime is only used in scan-test. A PR to conditionally disable that test would be welcome.

thesmurph added a commit to thesmurph/fmt that referenced this issue Nov 15, 2022
cygwin and embedded systems. By default newlib doesn't provide strptime
in time.h because it was added in a later X/Open versions. Issue: fmtlib#3178
vitaut pushed a commit that referenced this issue Nov 16, 2022
cygwin and embedded systems. By default newlib doesn't provide strptime
in time.h because it was added in a later X/Open versions. Issue: #3178
@vitaut vitaut closed this as completed Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants