cmake: fix to find snprintf #10155
I haven't had the time to check other configurations, but on my macOS Ventura 13.1 with XCode 14.2 cmake does not find `snprintf`. curl continues to build and work just fine, however since HAVE_SNPRINTF variable is cached, other dependencies (for example [json-c](https://github.com/json-c/json-c)) skip the check due to the way `check_symbol_exists` and assume that `snprintf` is not defined. Solution: ensure stdio.h is checked for definitions This way other dependencies have a fair shot at checking whether this function is available without being presented with a false negative.
I deleted that check in 4d73854, because it wasn't used in the curl codebase.
It seems unexpected to check for features we do not use locally (for a CMake novice at least).
Could this be solved by fixing our
If we end up checking for
Of course, the more significant underlying issue is how CMake's
I am not sure what you mean by "check for features we do not use locally"
Here's one use of HAVE_SNPRINTF here:
The surface is indeed tiny, but
I wonder if in fact curl never/rarely detects snprintf as being available? I just spun up a bare Ubuntu docker image and tried to build curl on it, and here's what I got:
This suggests that curl may be not using
Not sure about the implications of having HAVE_STDIO_H defined you had in mind. Can you elaborate?
This PR does not change the way the presence of this function is checked, it simply gives
@vszakats there's a check for snprintf:
But it is failing because stdio.h is not included
Got it. Still looks odd, and maintaining my opinion that a comment documenting this peculiarity would be useful. This could prevent accidentally deleting this check in the future because of no local macro references. If there is a more self-documenting way to force-include