diff --git a/src/config.h b/src/config.h
index 4d777c5e..a20af733 100644
--- a/src/config.h
+++ b/src/config.h
@@ -25,6 +25,10 @@
 
 #include "libavrdude.h"
 
+#if defined(WIN32) || defined(_MSC_VER) || defined(__MINGW32__)
+#define realpath(N,R) _fullpath((R), (N), PATH_MAX)
+#endif
+
 
 #define MAX_STR_CONST 1024
 
diff --git a/src/config_gram.y b/src/config_gram.y
index fa74bec9..2c6c1f46 100644
--- a/src/config_gram.y
+++ b/src/config_gram.y
@@ -30,10 +30,6 @@
 #include "libavrdude.h"
 #include "config.h"
 
-#if defined(_MSC_VER) || defined(__MINGW32__)
-#define realpath(N,R) _fullpath((R), (N), PATH_MAX)
-#endif
-
 #if defined(WIN32)
 #define strtok_r( _s, _sep, _lasts ) \
     ( *(_lasts) = strtok( (_s), (_sep) ) )