diff --git a/src/helper/jim.c b/src/helper/jim.c
index 28dc950db1999937e39a60a0eb2cf4cd2886fa76..bcea7c53ff2611053e9ac89766a9c2409046b2d7 100644
--- a/src/helper/jim.c
+++ b/src/helper/jim.c
@@ -49,7 +49,9 @@
 #define JIM_DYNLIB      /* Dynamic library support for UNIX and WIN32 */
 #endif /* JIM_ANSIC */
 
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE	/* for vasprintf() */
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/target/oocd_trace.c b/src/target/oocd_trace.c
index 55ea67caf63dcffcd77c96bdd3a637d669ab5242..e59c6203a8faa1918472d0573c01cb1ad25b390d 100644
--- a/src/target/oocd_trace.c
+++ b/src/target/oocd_trace.c
@@ -21,7 +21,9 @@
 #include "config.h"
 #endif
 
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif
 #include <string.h>
 #include <errno.h>