[Scons-users] CheckFunc doesn't give correct result due to "error: too few arguments to function"
Alex Fan
alex.fan.q at gmail.com
Fri Jan 6 20:24:04 EST 2023
And occasionally, this check can be overshadowed by c99's implicit function declaration if user writes something like,
env = Environment()
conf = Configure(env)
conf.CheckFunc(
'getxattr',
header=
'#include <sys/types.h>'
'#include <sys/xattr.h>'
)
The two macro gets concatenated in one line `#include <sys/types.h>#include <sys/xattr.h>`
gcc & clang thinks the second #include is invalid, but only issue a warning. Then scons generates the call as getxattr().
But because of implicit function declaration, getxattr() is implicitly defined, the compiler will succeed with no error, creating wrong check result.
This kind of misuse&bug is uncovered by clang-16 making implicit function declaration an error.
ref: https://discourse.llvm.org/t/configure-script-breakage-with-the-new-werror-implicit-function-declaration/65213/39
ref: https://github.com/sahib/rmlint/pull/605
________________________________
From: Alex Fan <alex.fan.q at gmail.com>
Sent: Saturday, January 7, 2023 11:21:46 AM
To: scons-users at scons.org <scons-users at scons.org>
Subject: CheckFunc doesn't give correct result due to "error: too few arguments to function"
Hi, Happy New Year
Reproducer:
env = Environment()
conf = Configure(env)
conf.CheckFunc(
'getxattr',
header=
'#include <sys/types.h>\n#include <sys/xattr.h>'
)
It produces a config.log like:
...
gcc -o .sconf_temp/conftest_c10cc6ce1defa319be0b1e0d1eeface9_0.o -c .sconf_temp/conftest_c10cc6ce1defa319be0b1e0d1eeface9_0.c
.sconf_temp/conftest_c10cc6ce1defa319be0b1e0d1eeface9_0.c: In function 'main':
.sconf_temp/conftest_c10cc6ce1defa319be0b1e0d1eeface9_0.c:15:3: error: too few arguments to function 'getxattr'
15 | getxattr();
| ^~~~~~~~
In file included from .sconf_temp/conftest_c10cc6ce1defa319be0b1e0d1eeface9_0.c:5:
/usr/include/sys/xattr.h:60:16: note: declared here
60 | extern ssize_t getxattr (const char *__path, const char *__name,
| ^~~~~~~~
scons: Configure: no
My gcc version is gcc version 11.3.1 20221209 (Gentoo 11.3.1_p20221209 p3)
Any clue if this can be fixed?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20230107/93868d8d/attachment.htm>
More information about the Scons-users
mailing list