Fix unknown pragma warnings under MSVC.
@@ -3,6 +3,24 @@ import subprocess
import argparse
import os
+header = '''\
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#pragma GCC diagnostic ignored "-Wmissing-braces"
+#pragma GCC diagnostic ignored "-Wuninitialized"
+#pragma GCC diagnostic ignored "-Wreturn-type"
+#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+#endif
+
+'''
+
+footer = '''
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+'''
+
if __name__ == '__main__':
parser = argparse.ArgumentParser()
@@ -25,10 +43,6 @@ if __name__ == '__main__':
print >>sys.stderr, stderr
with open(args.output, 'w') as f:
- f.write('#pragma clang diagnostic ignored "-Wunused-parameter"\n')
- f.write('#pragma clang diagnostic ignored "-Wmissing-braces"\n')
- f.write('#pragma clang diagnostic ignored "-Wuninitialized"\n')
- f.write('#pragma clang diagnostic ignored "-Wreturn-type"\n')
- f.write('#pragma clang diagnostic ignored "-Wmissing-field-initializers"\n')
-
+ f.write(header)
f.write(stdout)
+ f.write(footer)
