Closed matthewjmiller1 closed 1 year ago
I don't know why the FreeBSD headers are trying to use posix_memalign()
when _XOPEN_SOURCE=500. It looks like it is first available in 600.
That said, I'm keen to make things work for you in any case. Perhaps take a look at #224 and see if __FreeBSD__
might deserve similar logic to __OpenBSD__
. That is, does FreeBSD provide strptime()
by default?
It seems so.
$ cat test_strptime.cc
#undef _GNU_SOURCE
#ifdef __linux__
#define _XOPEN_SOURCE 500
#endif
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
int
main(int argc, char **argv)
{
struct tm tm;
char buf[255];
#ifdef _XOPEN_SOURCE
printf("_XOPEN_SOURCE: %u\n", _XOPEN_SOURCE);
#endif
memset(&tm, 0, sizeof(tm));
strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm);
strftime(buf, sizeof(buf), "%d %b %Y %H:%M", &tm);
puts(buf);
exit(EXIT_SUCCESS);
}
$
On Linux:
$ clang++ test_strptime.cc
$ ./a.out
_XOPEN_SOURCE: 500
12 Nov 2001 18:31
$
On FreeBSD:
$ clang++ test_strptime.cc
$ ./a.out
12 Nov 2001 18:31
$
It seems to build OK when adding __FreeBSD__
to that logic (and leaving _XOPEN_SOURCE undefined):
#if defined(HAS_STRPTIME) && HAS_STRPTIME
# if !defined(_XOPEN_SOURCE) && !defined(__OpenBSD__) && !defined(__FreeBSD__)
# define _XOPEN_SOURCE 500 // Exposes definitions for SUSv2 (UNIX 98).
# endif
#endif
Thanks. #271 out for review.
This commit regressed FreeBSD builds (I noticed this when attempting to build as part of abseil-cpp).
Attempting to compile on FreeBSD 13.1 gives:
However, if I set a more recent
_XOPEN_SOURCE
value, then the FreeBSD build succeeds: