How can I check if a function exists in waf?

Chris Johns chrisj at rtems.org
Sat Feb 2 01:07:02 UTC 2019


On 1/2/19 8:19 pm, Sebastian Huber wrote:
> 
> 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.

You have a powerful language available. I would create a function to handle
repeated checks, for example:

https://git.rtems.org/chrisj/rtems_waf.git/tree/rtems.py?h=libbsd-libdl#n270

I think having the ability to perform checks for an RTEMS application highlights
the power available.

Chris



More information about the devel mailing list