diff --git a/src/error.h b/src/error.h
index 4f137b6e91e257d56164ed91075566b10e50a742..ca8837024a4e35ece3a47fe0dfe30733199e808b 100644
--- a/src/error.h
+++ b/src/error.h
@@ -20,7 +20,10 @@
 
 typedef void (*error_call)(void *);
 
+#ifndef STRUCT_FRAME_DECLARED
+#define STRUCT_FRAME_DECLARED
 struct frame;
+#endif
 
 typedef struct ONERROR
 {
diff --git a/src/hashtable.h b/src/hashtable.h
index d8d0a7043666aa92b0c91dc844a757af69e33468..c5271c188ecf6dbe3d017b69631e23f556e523ad 100644
--- a/src/hashtable.h
+++ b/src/hashtable.h
@@ -11,12 +11,18 @@
 #define AVERAGE_HASH_LENGTH 16
 #define NEW_HASHTABLE_SIZE 4
 
+#ifndef STRUCT_HASH_ENTRY_DECLARED
+#define STRUCT_HASH_ENTRY_DECLARED
+#endif
 struct hash_entry
 {
   struct hash_entry *next;
   struct pike_string *s;
 };
 
+#ifndef STRUCT_HASH_TABLE_DECLARED
+#define STRUCT_HASH_TABLE_DECLARED
+#endif
 struct hash_table
 {
   INT32 mask;
diff --git a/src/interpret.h b/src/interpret.h
index 618d7b3de7926ae45f52c0189dea8e2e58aa41a7..3ae421679252c6021c51f126def00f059cd84741 100644
--- a/src/interpret.h
+++ b/src/interpret.h
@@ -9,6 +9,9 @@
 #include "program.h"
 #include "config.h"
 
+#ifndef STRUCT_FRAME_DECLARED
+#define STRUCT_FRAME_DECLARED
+#endif
 struct frame
 {
   unsigned char *pc;
diff --git a/src/lex.h b/src/lex.h
index 41d4ba9f72d73191f8335c00f963cb0be8510bf6..f5ce12941d12e8952269124e6444de8ac71b64a7 100644
--- a/src/lex.h
+++ b/src/lex.h
@@ -31,9 +31,20 @@ struct instr
 #define ADD_RUNNED(X)
 #endif
 
+#ifndef STRUCT_HASH_ENTRY_DECLARED
+#define STRUCT_HASH_ENTRY_DECLARED
 struct hash_entry;
+#endif
+
+#ifndef STRUCT_INPUTSTATE_DECLARED
+#define STRUCT_INPUTSTATE_DECLARED
 struct inputstate;
+#endif
+
+#ifndef STRUCT_HASH_TABLE_DECLARED
+#define STRUCT_HASH_TABLE_DECLARED
 struct hash_table;
+#endif
 
 extern struct instr instrs[];
 extern struct hash_table *defines;
diff --git a/src/port.h b/src/port.h
index 115792a9854ce6677441704ab9ec9dbca0245a8d..207f664478be474d333bc3c00eea37e2dea1de9d 100644
--- a/src/port.h
+++ b/src/port.h
@@ -8,7 +8,10 @@
 
 #include "types.h"
 
+#ifndef STRUCT_TIMEVAL_DECLARED
+#define STRUCT_TIMEVAL_DECLARED
 struct timeval;
+#endif
 #ifdef HAVE_ISSPACE
 #define ISSPACE(X) isspace(X)
 #else
diff --git a/src/program.h b/src/program.h
index 5849c82c5aca311e368ec3193165a0cbc7a59058..590861e5a8279a2f0e9f217cdee5ee2350b96696 100644
--- a/src/program.h
+++ b/src/program.h
@@ -38,9 +38,20 @@
 
 extern char *lfun_names[];
 
+#ifndef STRUCT_SVALUE_DECLARED
+#define STRUCT_SVALUE_DECLARED
 struct svalue;
+#endif
+
+#ifndef STRUCT_MODULE_DECLARED
+#define STRUCT_MODULE_DECLARED
 struct module;
+#endif
+
+#ifndef STRUCT_OBJECT_DECLARED
+#define STRUCT_OBJECT_DECLARED
 struct object;
+#endif
 
 /* I need:
  * a) one type that can point to a callable function.
diff --git a/src/svalue.h b/src/svalue.h
index cbbbac02cbf7c0c2916e2957ac01f83226a15b0f..3fe7aec8e2a3a3d6d5af0432281e3b5cdac43819 100644
--- a/src/svalue.h
+++ b/src/svalue.h
@@ -8,13 +8,40 @@
 
 #include "types.h"
 
+#ifndef STRUCT_ARRAY_DECLARED
+#define STRUCT_ARRAY_DECLARED
 struct array;
+#endif
+
+#ifndef STRUCT_MAPPING_DECLARED
+#define STRUCT_MAPPING_DECLARED
 struct mapping;
+#endif
+
+#ifndef STRUCT_MULTISET_DECLARED
+#define STRUCT_MULTISET_DECLARED
 struct multiset;
+#endif
+
+#ifndef STRUCT_OBJECT_DECLARED
+#define STRUCT_OBJECT_DECLARED
 struct object;
+#endif
+
+#ifndef STRUCT_PROGRAM_DECLARED
+#define STRUCT_PROGRAM_DECLARED
 struct program;
+#endif
+
+#ifndef STRUCT_PIKE_STRING_DECLARED
+#define STRUCT_PIKE_STRING_DECLARED
 struct pike_string;
+#endif
+
+#ifndef STRUCT_CALLABLE_DECLARED
+#define STRUCT_CALLABLE_DECLARED
 struct callable;
+#endif
 
 struct processing
 {
@@ -38,6 +65,9 @@ union anything
   union anything *short_lval;   /* only used on stack */
 };
 
+#ifndef STRUCT_SVALUE_DECLARED
+#define STRUCT_SVALUE_DECLARED
+#endif
 struct svalue
 {
   unsigned INT16 type;
diff --git a/src/time_stuff.h b/src/time_stuff.h
index 907aa613e37a4ef5445cc951086b3414df3157d5..f268a4154a80e22f3f40157708ecf200d2bbd8fa 100644
--- a/src/time_stuff.h
+++ b/src/time_stuff.h
@@ -53,6 +53,9 @@
   } while(0)
 
 #ifndef HAVE_STRUCT_TIMEVAL
+#ifndef STRUCT_TIMEVAL_DECLARED
+#define STRUCT_TIMEVAL_DECLARED
+#endif
 struct timeval
 {
   long tv_sec;