From 9b4965e100c7190dc5865bd6db7bfce5d484a822 Mon Sep 17 00:00:00 2001 From: rfm Date: Sun, 19 Jan 2025 10:23:33 +0000 Subject: [PATCH] define function in NSObject.m so that it won't be omitted by clever linkers --- Source/NSEnumerator.m | 9 --------- Source/NSObject.m | 10 ++++++++++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Source/NSEnumerator.m b/Source/NSEnumerator.m index cf6735b33..96ca2e365 100644 --- a/Source/NSEnumerator.m +++ b/Source/NSEnumerator.m @@ -97,12 +97,3 @@ } @end -/** - * objc_enumerationMutation() is called whenever a collection mutates in the - * middle of fast enumeration. - */ -void objc_enumerationMutation(id obj) -{ - [NSException raise: NSGenericException - format: @"Collection %@ was mutated while being enumerated", obj]; -} diff --git a/Source/NSObject.m b/Source/NSObject.m index eb74ca365..4ee876b9a 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -83,6 +83,16 @@ #endif #endif +/* objc_enumerationMutation() is called whenever a collection mutates in the + * middle of fast enumeration. We need to have this defined and linked into + * any code that uses fast enumeration, so we define it in NSObject.h + */ +void objc_enumerationMutation(id obj) +{ + [NSException raise: NSGenericException + format: @"Collection %@ was mutated while being enumerated", obj]; +} + /* platforms which do not support weak */ #if defined (__WIN32) #define WEAK_ATTRIBUTE