diff --git a/libavformat/os_support.c b/libavformat/os_support.c
index 652da346fcd9df73657ff777907a8d2cf096d32a..079a8a9fc181edc759aab0d0f41af2ca6c1fe7f0 100644
--- a/libavformat/os_support.c
+++ b/libavformat/os_support.c
@@ -53,8 +53,7 @@ int64_t av_gettime(void)
 #endif
 }
 
-#if !defined(CONFIG_WINCE)
-#if !defined(HAVE_LOCALTIME_R)
+#if !defined(CONFIG_WINCE) && !defined(HAVE_LOCALTIME_R)
 struct tm *localtime_r(const time_t *t, struct tm *tp)
 {
     struct tm *l;
@@ -65,5 +64,4 @@ struct tm *localtime_r(const time_t *t, struct tm *tp)
     *tp = *l;
     return tp;
 }
-#endif /* !defined(HAVE_LOCALTIME_R) */
-#endif /* !defined(CONFIG_WINCE) */
+#endif /* !defined(CONFIG_WINCE) && !defined(HAVE_LOCALTIME_R) */