Skip to content

prom: missing include for 'sprintf'#2

Open
linuxmaniac wants to merge 2 commits into
jelmd:mainfrom
linuxmaniac:vseva/fix
Open

prom: missing include for 'sprintf'#2
linuxmaniac wants to merge 2 commits into
jelmd:mainfrom
linuxmaniac:vseva/fix

Conversation

@linuxmaniac

Copy link
Copy Markdown

/<>/prom/src/prom_histogram_buckets.c: In function ‘double_to_str’:
/<>/prom/src/prom_histogram_buckets.c:34:19: error: implicit declaration of function ‘sprintf’ [-Werror=implicit-function-declaration]
34 | int len = sprintf(buf, "%.17g", value);
| ^~~~~~~
/<>/prom/src/prom_histogram_buckets.c:28:1: note: include ‘<stdio.h>’ or provide a declaration of ‘sprintf’
27 | #include "prom_log.h"
+++ |+#include <stdio.h>
28 |
/<>/prom/src/prom_histogram_buckets.c:34:19: error: incompatible implicit declaration of built-in function ‘sprintf’ [-Werror=builtin-declaration-mismatch]
34 | int len = sprintf(buf, "%.17g", value);
| ^~~~~~~
/<>/prom/src/prom_histogram_buckets.c:34:19: note: include ‘<stdio.h>’ or provide a declaration of ‘sprintf’

jelmd and others added 2 commits November 21, 2023 14:47
> /<<PKGBUILDDIR>>/prom/src/prom_histogram_buckets.c: In function ‘double_to_str’:
> /<<PKGBUILDDIR>>/prom/src/prom_histogram_buckets.c:34:19: error: implicit declaration of function ‘sprintf’ [-Werror=implicit-function-declaration]
>    34 |         int len = sprintf(buf, "%.17g", value);
>       |                   ^~~~~~~
> /<<PKGBUILDDIR>>/prom/src/prom_histogram_buckets.c:28:1: note: include ‘<stdio.h>’ or provide a declaration of ‘sprintf’
>    27 | #include "prom_log.h"
>   +++ |+#include <stdio.h>
>    28 |
> /<<PKGBUILDDIR>>/prom/src/prom_histogram_buckets.c:34:19: error: incompatible implicit declaration of built-in function ‘sprintf’ [-Werror=builtin-declaration-mismatch]
>    34 |         int len = sprintf(buf, "%.17g", value);
>       |                   ^~~~~~~
> /<<PKGBUILDDIR>>/prom/src/prom_histogram_buckets.c:34:19: note: include ‘<stdio.h>’ or provide a declaration of ‘sprintf’
@jelmd jelmd force-pushed the main branch 3 times, most recently from b9ee077 to 01b03d5 Compare February 25, 2026 04:46

#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide more info on your environment. Can't see this problem on any Ubuntu/Illumos/Solaris host,

@GerMalaz GerMalaz Mar 27, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow, in Debian this happens (besides other small differences)

+++ ./prom/build.debian/CMakeFiles/prom.dir/src/prom_histogram_buckets.c.o.d	2026-03-27 07:07:48.642938782 +0000
- /home/gerardo/apt-src/libprom-1.2.1.jelmd/prom/include/prom_log.h \
- /usr/include/stdio.h /usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h \
- /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \
- /usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h \
- /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \
- /usr/include/x86_64-linux-gnu/bits/types/FILE.h \
- /usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h \
- /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
- /usr/include/x86_64-linux-gnu/bits/stdio.h
+ /home/gerardo/apt-src/libprom-1.2.1.jelmd/prom/include/prom_log.h

This is due to the definition of PROM_LOG_ENABLE in CFLAGS, missing in debian's CFLAGS (side question: why?)
As the included prom_log.h includes stdio.h when PROM_LOG_ENABLE is defined, cmake picks up the needed include files.
However, prom_histogram_buckets.c needs the patch here on its own, due to sprintf usage.

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

Successfully merging this pull request may close these issues.

3 participants