Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2b1179f

Browse files
committed
FEAT: add check to ensure compilation without warning for a piece of code.
1 parent 4769fe7 commit 2b1179f

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

numpy/distutils/command/autodist.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,10 @@ def check_gcc_function_attribute(cmd, attribute, name):
5858
if not ret or len(output) > 0:
5959
return False
6060
return True
61+
62+
def check_compile_without_warning(cmd, body):
63+
cmd._check_compiler()
64+
ret, output = cmd.try_output_compile(body, None, None)
65+
if not ret or len(output) > 0:
66+
return False
67+
return True

numpy/distutils/command/config.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
from numpy.distutils.exec_command import exec_command
1818
from numpy.distutils.mingw32ccompiler import generate_manifest
1919
from numpy.distutils.command.autodist import (check_gcc_function_attribute,
20-
check_inline, check_compiler_gcc4)
20+
check_inline,
21+
check_compiler_gcc4,
22+
check_compile_without_warning)
2123
from numpy.distutils.compat import get_exception
2224

2325
LANG_EXT['f77'] = '.f'
@@ -426,6 +428,10 @@ def check_compiler_gcc4(self):
426428
def check_gcc_function_attribute(self, attribute, name):
427429
return check_gcc_function_attribute(self, attribute, name)
428430

431+
def check_compile_without_warning(self, code):
432+
"""Returns True if the given code may be compiled without warning."""
433+
return check_compile_without_warning(self, code)
434+
429435
def get_output(self, body, headers=None, include_dirs=None,
430436
libraries=None, library_dirs=None,
431437
lang="c", use_tee=None):

0 commit comments

Comments
 (0)