diff --git a/src/include/port.h b/src/include/port.h
index 0c2b236..369bda1 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -308,9 +308,15 @@ extern FILE *pgwin32_fopen(const char *, const char *);
 extern int	pgwin32_system(const char *command);
 extern FILE *pgwin32_popen(const char *command, const char *type);
 
+#ifndef system
 #define system(a) pgwin32_system(a)
+#endif
+#ifndef popen
 #define popen(a,b) pgwin32_popen(a,b)
+#endif
+#ifndef pclose
 #define pclose(a) _pclose(a)
+#endif
 
 /* New versions of MingW have gettimeofday, old mingw and msvc don't */
 #ifndef HAVE_GETTIMEOFDAY
