Fix a few minor build issues on musl#112
Conversation
Without this the build can fail on musl:
connect.c: In function '_iodbcdm_pool_set_retry_wait':
connect.c:489:25: error: implicit declaration of function 'time'
[-Wimplicit-function-declaration]
489 | pdbc->cp_retry_wait = time(NULL) + retry_wait;
| ^~~~
Presumably glibc includes time.h incidentally via some other header.
Without this, the build can fail on musl:
info.c: In function 'SQLDrivers_Internal':
../include/iodbc.h:117:34: error: implicit declaration of function
'strcasecmp'; did you mean 'wcscasecmp'?
[-Wimplicit-function-declaration]
117 | #define STRCASEEQ(a, b) (strcasecmp((char*)(a), (char*)(b)) == 0)
| ^~~~~~~~~~
Presumably glibc includes strings.h incidentally via some other
header.
Without this, the build can fail on musl:
SQLGetInstalledDrivers.c: In function 'SQLGetInstalledDrivers_Internal':
../include/iodbc.h:117:34: error: implicit declaration of function
'strdup'; did you mean 'strcmp'? [-Wimplicit-function-declaration]
117 | #define STRDUP(t) (strdup((char*)(t)))
| ^~~~~~
| #ifndef _POSIX_C_SOURCE | ||
| /* POSIX.1-2008 is required for strdup() */ | ||
| #define _POSIX_C_SOURCE 200809L | ||
| #endif |
There was a problem hiding this comment.
#else error out if _POSIX_C_SOURCE < 200809L?
There was a problem hiding this comment.
It already errors, that's how I noticed :)
It would be nice to show the error as early as possible, but there's a small risk of breaking things for people with other C libraries. Clearly it works on glibc without the define, otherwise everyone would have noticed. But does it work on glibc with some earlier constant defined? (I don't know). If it does, then turning that into an error would probably be bad, even though anyone defining _POSIX_C_SOURCE to something less than 2008 has asked for it.
There was a problem hiding this comment.
Yeah, I meant an earlier/more explicit error.
I'm on the side of 'fail fast', so I would welcome such 'breakage', but I know not everyone agrees
Attempting to build iODBC on a musl system, I hit a few "missing function" errors that turned out to be quick fixes. Two were missing includes, and one required a feature test macro to enable
strdup().