Implicit snprintf declaration

I noticed that when I compile this iniparser , it highlights the following warning:

 src/iniparser.c:244:5: warning: implicit declaration of function β€˜snprintf’ [-Wimplicit-function-declaration]
     snprintf(keym, secsize, "%s:", s);

The solution was supposed to add:

#include <stdio.h>

I tried this, but only this did not solve the problem. Then I looked at the compilation flags inside the Makefile and found this:

 CFLAGS  += -fPIC -Wall -ansi -pedantic

If I changed this to:

 CFLAGS  += -fPIC -Wall -std=c99 -pedantic

Compiled without warning. Does this mean that the C90 standard does not include snprintf? Can someone explain this behavior to me?

+4
source share
1 answer

snprintfindicated only in C99, unlike sprintfthat found on the C90. See man sprintffor more information.

+4
source

Source: https://habr.com/ru/post/1533427/


All Articles