Closed pmqs closed 6 months ago
The Ubuntu clang complaint makes sense, since C89/C90 doesn't have snprintf()
or vsnprintf()
. They were introduced in C99.
The Ubuntu clang complaint makes sense, since C89/C90 doesn't have
snprintf()
orvsnprintf()
. They were introduced in C99.
Then the clang C89/90 behaviour with configure is (at least) inconsistent as it builds without warning.
As does gcc with C89.
Admittedly, this is an edge condition -- goodness knows if anyone has a valid use case that needs C89 these days.
I'm sure the cmake code can be made to do make everything consistent if needed. I just don't know it well enough to hack it.
Either that or set a minimum C spec that the code needs to conform to.
Until very recently (VS 2022), Microsoft Visual C only supported C89/90. However it does have, and has had, snprintf()
and vsnprintf()
. Recently it claims to support C11 and C17, but only if you request it with the respective compiler options.
I am thinking of checking __STDC__
, __STDC_VERSION__
, and _WIN32
to deduce whether those functions are missing or not, in addition to the configure checks.
Then the clang C89/90 behaviour with configure is (at least) inconsistent as it builds without warning.
configure checks directly for those functions, and doesn't use them if they're not there.
Until very recently (VS 2022), Microsoft Visual C only supported C89/90. However it does have, and has had,
snprintf()
andvsnprintf()
. Recently it claims to support C11 and C17, but only if you request it with the respective compiler options.
Crikey! C89 is not an edge condition at all then.
I am thinking of checking
__STDC__
,__STDC_VERSION__
, and_WIN32
to deduce whether those functions are missing or not, in addition to the configure checks.
I think that should be enough to catch the clang use-case I highlighted.
Hopefully no need to add cmake code to mirror the check-by-compilation test that configure does for vsnprintf
I have pushed some commits on the develop branch. Let me know how that works for you.
I have pushed some commits on the develop branch. Let me know how that works for you.
Thanks, that silences the warnings
This is taken from https://github.com/madler/zlib/pull/926#issuecomment-1929291276
Seeing the warnings below with c89 (and iso9899:199409) + clang + cmake on Ubuntu. The equivalent Mac build is fine. Also there is no issue when built with configure, so the issue must lie with
zconf.h
and/or the clang commandline.Adding
-DNO_vsnprintf
toCFLAGS
sorts this issue. Fix needed is to getCMakesList.txt
to do the equivalent test thatconfigure
does forvsnprintf
.The cmake function check_c_source_compiles looks like a candidate for this change.