argtable / argtable3

A single-file, ANSI C, command-line parsing library that parses GNU-style command-line options.
http://www.argtable.org
Other
372 stars 65 forks source link

Implicit declaration of function 'vsnprintf' #55

Open Kerl13 opened 3 years ago

Kerl13 commented 3 years ago

When compiling the argtable3.c file produced by tools/build dist (as of fe70fd5) with gcc version 10.2.0, I get the following warning:

$ cc --version
cc (GCC) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ cc -Wall -Wextra -pedantic -ansi -c argtable3.c
argtable3.c: In function 'arg_dstr_catf':
argtable3.c:1104:13: warning: implicit declaration of function 'vsnprintf'; did you mean 'vsprintf'? [-Wimplicit-function-declaration]
 1104 |         r = vsnprintf(buff, n + 1, fmt, arglist);
      |             ^~~~~~~~~
      |             vsprintf

From the man page, vsnprintf seems to only be available starting from C99

tomghuang commented 3 years ago

@Kerl13 , you're right, vsnprintf seems to be a new C standard function. Would you mind providing a patch, so that it can work in older compilers? Thanks.

Kerl13 commented 3 years ago

I can look into this! But maybe not before one week or two when I have more time