From af55c290079f207144ee3e836244a0fda6d25f09 Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Tue, 30 Jul 2019 14:28:59 +0100 Subject: [PATCH] Fix the build on Windows. --- arc.mm | 22 +++++++++++++++++++--- class.h | 8 ++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/arc.mm b/arc.mm index 9e34caa..4070017 100644 --- a/arc.mm +++ b/arc.mm @@ -56,9 +56,12 @@ static inline arc_tls_key_t arc_tls_key_create(arc_cleanup_function_t cleanupFun arc_tls_key_t ARCThreadKey; #endif -extern struct objc_class _NSConcreteMallocBlock; -extern struct objc_class _NSConcreteStackBlock; -extern struct objc_class _NSConcreteGlobalBlock; +extern "C" +{ + extern struct objc_class _NSConcreteMallocBlock; + extern struct objc_class _NSConcreteStackBlock; + extern struct objc_class _NSConcreteGlobalBlock; +} @interface NSAutoreleasePool + (Class)class; @@ -639,10 +642,23 @@ struct malloc_allocator { return static_cast(malloc(sizeof(T) * n)); } + void deallocate(T* p, std::size_t) { free(p); } + + template + malloc_allocator &operator=(const malloc_allocator&) const + { + return *this; + } + + bool operator==(const malloc_allocator &) const + { + return true; + } + template operator malloc_allocator() const { diff --git a/class.h b/class.h index 8aa17ba..20e8cf9 100644 --- a/class.h +++ b/class.h @@ -4,6 +4,11 @@ #include "objc/runtime.h" #include +#ifdef __cplusplus +extern "C" +{ +#endif + /** * Overflow bitfield. Used for bitfields that are more than 63 bits. */ @@ -443,4 +448,7 @@ void freeIvarLists(Class aClass); */ void freeMethodLists(Class aClass); +#ifdef __cplusplus +} // extern "C" +#endif #endif //__OBJC_CLASS_H_INCLUDED