diff --git a/binding.gyp b/binding.gyp
index 6c6b3cfc79918ac7d6e6f5a0a71fb578c5439c37..51548682063423fe32749a68746b29043bad9f27 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -771,9 +771,10 @@
     },
     {
       'cflags': [
+        '-std=c99',
         '-Wall',
         '-Werror',
-        '-Wno-implicit-function-declaration'
+        '-Wno-invalid-source-encoding',
       ],
       'include_dirs': [ 'src/c-ares' ],
       'target_name': 'ares',
@@ -833,6 +834,12 @@
         'third_party/c-ares/windows_port.c',
       ],
       "conditions": [
+        ['OS != "win"', {
+          'defines': [
+            'HAVE_CONFIG_H',
+            '_GNU_SOURCE'
+          ]
+          }],
         ['OS == "mac"', {
           'xcode_settings': {
             'MACOSX_DEPLOYMENT_TARGET': '10.9'
diff --git a/templates/binding.gyp.template b/templates/binding.gyp.template
index c5549e5cad24339677b9d8445260d2dab1fab2f7..2da9785201a091dc72db63e312f2fbffbca8a8be 100644
--- a/templates/binding.gyp.template
+++ b/templates/binding.gyp.template
@@ -209,9 +209,10 @@
       % if lib.name == 'ares':
       {
         'cflags': [
+          '-std=c99',
           '-Wall',
           '-Werror',
-          '-Wno-implicit-function-declaration'
+          '-Wno-invalid-source-encoding',
         ],
         'include_dirs': [ 'src/c-ares' ],
         'target_name': '${lib.name}',
@@ -225,6 +226,12 @@
           % endfor
         ],
         "conditions": [
+          ['OS != "win"', {
+            'defines': [
+              'HAVE_CONFIG_H',
+              '_GNU_SOURCE'
+            ]
+            }],
           ['OS == "mac"', {
             'xcode_settings': {
               'MACOSX_DEPLOYMENT_TARGET': '10.9'