[Scons-users] CheckFunc doesn't give correct result due to "error: too few arguments to function"

Mats Wichmann mats at wichmann.us
Sat Jan 7 07:38:20 EST 2023


On 1/6/23 17:21, Alex Fan wrote:
> 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 isgcc version 11.3.1 20221209 (Gentoo 11.3.1_p20221209 p3)
> 
> Any clue if this can be fixed?

Yes - leave out the header argument.

The docs are quite poor here, sorry.  CheckFunc is only used to see if 
you can successfully link a test program without getting a linker error. 
The default generated header will declare a dummy prototype so you don't 
get the implicit declaration complaints, and you don't include any 
header files because then you'll pick up a prototype that doesn't match 
how the function is called . So:

env = Environment()
conf = Configure(env)
res = conf.CheckFunc('getxattr')
conf.Finish()

The test generates like this, which should work fine:

.sconf_temp/conftest_1a85045c4b3639192e805fd2b7ba2715_0.c <-
   |
   |
   |#include <assert.h>
   |
   |#ifdef __cplusplus
   |extern "C"
   |#endif
   |char getxattr();
   |
   |#if _MSC_VER && !__INTEL_COMPILER
   |    #pragma function(getxattr)
   |#endif
   |
   |int main(void) {
   |#if defined (__stub_getxattr) || defined (__stub___getxattr)
   |  fail fail fail
   |#else
   |  getxattr();
   |#endif
   |
   |  return 0;
   |}
   |




More information about the Scons-users mailing list