def is_flag_supported(flag: str, compiler: CCompiler) -> bool: with tempfile.NamedTemporaryFile('w', suffix='.cpp') as file: file.write('int main(void) { return 0; }') try: compiler.compile([file.name], extra_postargs=[flag]) except CompileError: return False return True
def has_flag(compiler: CCompiler, value: str) -> bool: """Detects whether a flag name is supported on the specified compiler.""" with tempfile.NamedTemporaryFile('w', suffix='.cpp') as file: file.write('int main (int argc, char **argv) { return 0; }') try: compiler.compile([file.name], extra_postargs=[value]) except CompileError: return False return True