Forráskód Böngészése

core:sr_module If offsetof is not found in stddef.h define it as a macro

This is very unlikely; the macro uses the null pointer dereference
Marius Zbihlei 15 éve
szülő
commit
b4c42f7bf3
1 módosított fájl, 5 hozzáadás és 1 törlés
  1. 5 1
      sr_module.c

+ 5 - 1
sr_module.c

@@ -101,11 +101,15 @@ struct sr_module* modules=0;
 	extern struct module_exports sl_exports;
 #endif
 
+#ifndef offsetof
+#warning "use null pointer dereference for offsetof"
+#define offsetof(st, m) \
+		((size_t) ( (char *)&((st *)(0))->m - (char *)0 ))
+#endif
 
 int mod_response_cbk_no=0;
 response_function* mod_response_cbks=0;
 
-
 /* initializes statically built (compiled in) modules*/
 int register_builtin_modules()
 {