Skip to content

Commit

Permalink
Merge pull request #205 from fweimer-rh/ccompiler-include
Browse files Browse the repository at this point in the history
distutils.ccompiler.CCompiler.has_function: Quote #include argument
  • Loading branch information
jaraco authored Feb 20, 2023
2 parents 8c3c3d2 + b022b25 commit 4435cec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion distutils/ccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ def has_function( # noqa: C901
f = os.fdopen(fd, "w")
try:
for incl in includes:
f.write("""#include %s\n""" % incl)
f.write("""#include "%s"\n""" % incl)
if not includes:
# Use "char func(void);" as the prototype to follow
# what autoconf does. This prototype does not match
Expand Down
6 changes: 3 additions & 3 deletions distutils/tests/test_ccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ def test_has_function_prototype():
assert compiler.has_function('exit')
with pytest.deprecated_call(match='includes is deprecated'):
# abort() is a valid expression with the <stdlib.h> prototype.
assert compiler.has_function('abort', includes=['<stdlib.h>'])
assert compiler.has_function('abort', includes=['stdlib.h'])
with pytest.deprecated_call(match='includes is deprecated'):
# But exit() is not valid with the actual prototype in scope.
assert not compiler.has_function('exit', includes=['<stdlib.h>'])
assert not compiler.has_function('exit', includes=['stdlib.h'])
# And setuptools_does_not_exist is not declared or defined at all.
assert not compiler.has_function('setuptools_does_not_exist')
with pytest.deprecated_call(match='includes is deprecated'):
assert not compiler.has_function(
'setuptools_does_not_exist', includes=['<stdio.h>']
'setuptools_does_not_exist', includes=['stdio.h']
)


Expand Down

0 comments on commit 4435cec

Please sign in to comment.