summaryrefslogtreecommitdiffstats
path: root/SCons/Conftest.py
diff options
context:
space:
mode:
authorJoseph Brill <48932340+jcbrill@users.noreply.github.com>2023-11-24 15:50:13 (GMT)
committerJoseph Brill <48932340+jcbrill@users.noreply.github.com>2023-11-24 15:50:13 (GMT)
commitedc14d6647d3819a9c6ee076ccc3c65f2283600b (patch)
treebd702fd1cc6eb7ed504f38e0248fbc7bcfc87903 /SCons/Conftest.py
parentb760704543953ca82a9d9a422667394c4fcb39b9 (diff)
downloadSCons-edc14d6647d3819a9c6ee076ccc3c65f2283600b.zip
SCons-edc14d6647d3819a9c6ee076ccc3c65f2283600b.tar.gz
SCons-edc14d6647d3819a9c6ee076ccc3c65f2283600b.tar.bz2
Fix 4320: add an optional argument list string to the configure CheckFunc method.
Add an optional argument list string so the generated function argument list matches the function's prototype when including a header file.
Diffstat (limited to 'SCons/Conftest.py')
-rw-r--r--SCons/Conftest.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/SCons/Conftest.py b/SCons/Conftest.py
index 6af5e78..cd122e7 100644
--- a/SCons/Conftest.py
+++ b/SCons/Conftest.py
@@ -231,13 +231,15 @@ def _check_empty_program(context, comp, text, language, use_shared: bool = False
return context.CompileProg(text, suffix)
-def CheckFunc(context, function_name, header = None, language = None):
+def CheckFunc(context, function_name, header = None, language = None, funcargs = None):
"""
Configure check for a function "function_name".
"language" should be "C" or "C++" and is used to select the compiler.
Default is "C".
Optional "header" can be defined to define a function prototype, include a
header file or anything else that comes before main().
+ Optional "funcargs" can be defined to define an argument list for the
+ generated function invocation.
Sets HAVE_function_name in context.havedict according to the result.
Note that this uses the current value of compiler and linker flags, make
sure $CFLAGS, $CPPFLAGS and $LIBS are set correctly.
@@ -274,6 +276,9 @@ char %s(void);""" % function_name
context.Display("Cannot check for %s(): %s\n" % (function_name, msg))
return msg
+ if not funcargs:
+ funcargs = ''
+
text = """
%(include)s
#include <assert.h>
@@ -287,14 +292,15 @@ int main(void) {
#if defined (__stub_%(name)s) || defined (__stub___%(name)s)
#error "%(name)s has a GNU stub, cannot check"
#else
- %(name)s();
+ %(name)s(%(args)s);
#endif
return 0;
}
""" % { 'name': function_name,
'include': includetext,
- 'hdr': header }
+ 'hdr': header,
+ 'args': funcargs}
context.Display("Checking for %s function %s()... " % (lang, function_name))
ret = context.BuildProg(text, suffix)