diff --git a/mongoose.h b/mongoose.h
index d58667ff28f2ccab8f2d9b6ddc1ec3aff2716ae5..32fca84e3b202e01a5fdd061dac78c5dd124095d 100644
--- a/mongoose.h
+++ b/mongoose.h
@@ -868,7 +868,13 @@ typedef struct stat cs_stat_t;
 #define CS_COMMON_PLATFORMS_PLATFORM_MBED_H_
 #if CS_PLATFORM == CS_P_MBED
 
+/*
+ * mbed.h contains C++ code (e.g. templates), thus, it should be processed
+ * only if included directly to startup file (ex: main.cpp)
+ */
+#ifdef __cplusplus
 /* Amalgamated: #include "mbed.h" */
+#endif
 
 #include <assert.h>
 #include <ctype.h>