diff --git a/GNUmakefile b/GNUmakefile index dd65d80..f4e73ab 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -84,6 +84,7 @@ ifeq ($(boehm_gc), yes) libobjc_C_FILES += gc_boehm.c libobjc_LIBRARIES_DEPEND_UPON += -lgc-threaded libobjc_OBJCFLAGS += -fobjc-gc +libobjc_CPPFLAGS += -DENABLE_GC endif diff --git a/gc_boehm.c b/gc_boehm.c index dc5697b..35e2ad3 100644 --- a/gc_boehm.c +++ b/gc_boehm.c @@ -10,7 +10,7 @@ #include #include "gc_ops.h" #define I_HIDE_POINTERS -#include +#include #include #ifndef __clang__ diff --git a/gc_none.c b/gc_none.c index 784b64e..569e5b3 100644 --- a/gc_none.c +++ b/gc_none.c @@ -3,6 +3,7 @@ #include "gc_ops.h" #include "class.h" #include +#include static id allocate_class(Class cls, size_t extraBytes) { @@ -24,3 +25,12 @@ PRIVATE struct gc_ops *gc = &gc_ops_none; PRIVATE BOOL isGCEnabled = NO; +#ifndef ENABLE_GC +PRIVATE void enableGC(BOOL exclusive) +{ + fprintf(stderr, "Attempting to enable garbage collection, but your" + "Objective-C runtime was built without garbage collection" + "support\n"); + abort(); +} +#endif diff --git a/gc_ops.h b/gc_ops.h index 31babac..9cda3f0 100644 --- a/gc_ops.h +++ b/gc_ops.h @@ -32,6 +32,7 @@ struct gc_ops * -release / -autorelease messages become no-ops. */ void enableGC(BOOL exclusive); + /** * The mode for garbage collection */