How can I check if a function exists in waf?

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Feb 1 09:19:40 UTC 2019


On 01/02/2019 10:06, Vijay Kumar Banerjee wrote:
>
> On Fri, 1 Feb 2019 at 12:13, Sebastian Huber 
> <sebastian.huber at embedded-brains.de 
> <mailto:sebastian.huber at embedded-brains.de>> wrote:
>
>     Hello,
>
>     how can I check if a function exists in waf (similar to
>     AC_CHECK_FUNC)?
>     Currently, we get this output from the RTEMS tools waf configure
>     (please
>     note the "Invalid argument 'function_name' in test"):
>
> Hi,
>
> The support for 'function_name' has been removed since waf 2 as it
> was broken ( see 
> https://gitlab.com/ita1024/waf/blob/master/waflib/Tools/c_config.py#L420)

Nice.

>
> I guess the best option is to just use 'header_name' or to use the 
> 'fragment' parameter to write a fragment that calls the desired function.

So, there is no standard compile and link test for functions? If I use this

     conf.check_cc(fragment = 'int main(void) { strnlen("", 0); return 
0; }',
                   header_name="string.h", features = 'c', mandatory = 
False)

waf outputs

Checking for header string.h                  : yes

I don't want to test for string.h, I want to test for strnlen(). In 
config.log we have:

---------------------------------------------
Checking for header string.h
==>
int main(void) { strnlen("", 0); return 0; }
<==
[1/1] Compiling 
build/.conf_check_6da1e91772980301eb2528a1d150a7ab/test.c

['/usr/bin/gcc', '../test.c', '-c', 
'-o/scratch/git-rtems-tools/build/.conf_check_6da1e91772980301eb2528a1d150a7ab/testbuild/test.c.1.o']
err: ../test.c: In function ‘main’:
../test.c:1:18: warning: implicit declaration of function ‘strnlen’ 
[-Wimplicit-function-declaration]
  int main(void) { strnlen("", 0); return 0; }
                   ^~~~~~~

yes
---------------------------------------------

So, this test uses already quite some code and still is basically useless.

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.




More information about the devel mailing list