How can I check if a function exists in waf?
Sebastian Huber
sebastian.huber at embedded-brains.de
Sat Feb 2 10:12:03 UTC 2019
----- Am 2. Feb 2019 um 2:07 schrieb Chris Johns chrisj at rtems.org:
> 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 [32mbuild/.conf_check_6da1e91772980301eb2528a1d150a7ab/test.c[0m
>>
>> ['/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.
Yes, I don't doubt that you can do a lot of things with Python, but it was a bit surprising to me that I have to write custom code for things which are covered by basic Autoconf macros and only because Microsoft is not able to ship an operating system with a strnlen() function.
More information about the devel
mailing list