diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py index b71d1d3..00645db 100644 --- a/Lib/distutils/ccompiler.py +++ b/Lib/distutils/ccompiler.py @@ -800,6 +800,23 @@ main (int argc, char **argv) { return False return True + def has_flag(self, flagname): + """Return a boolean indicating whether a flag name is supported on + the specified compiler. + """ + import tempfile + fd, fname = tempfile.mkstemp('.cpp', 'main', text=True) + f = os.fdopen(fd, 'w') + try: + f.write('int main (int argc, char **argv) { return 0; }') + finally: + f.close() + try: + self.compile([fname], extra_postargs=[flagname]) + except setuptools.distutils.errors.CompileError: + return False + return True + def find_library_file (self, dirs, lib, debug=0): """Search the specified list of directories for a static or shared library file 'lib' and return the full path to that file. If