Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -42,28 +42,10 @@ AX_CHECK_COMPILER_FLAGS(-Wsemicolon-before-method-body, [OBJCFLAGS="$OBJCFLAGS -Wsemicolon-before-method-body"]) AX_CHECK_COMPILER_FLAGS(-Wno-objc-root-class, [OBJCFLAGS="$OBJCFLAGS -Wno-objc-root-class"]) -AC_MSG_CHECKING(whether Objective C compiler supports fast enumeration) -AC_TRY_COMPILE([ - @protocol OFFastEnumeration - - (int)countByEnumeratingWithState: (void*)state - objects: (id*)objects - count: (int)count; - @end -], [ - id n = (id)0; - for (id i in n); -], [ - AC_DEFINE(OF_HAVE_FAST_ENUMERATION, 1, - [Compiler support for Fast Enumeration]) - AC_MSG_RESULT(yes) -], [ - AC_MSG_RESULT(no) -]) - AC_MSG_CHECKING(whether Objective C compiler supports properties) AC_TRY_COMPILE([ @interface Foo { id bar; @@ -74,36 +56,13 @@ ], [ Foo *foo = (id)0; [foo setBar: (id)0]; [foo bar]; ], [ - AC_DEFINE(OF_HAVE_PROPERTIES, 1, [Compiler support for properties]) AC_SUBST(PROPERTIESTESTS_M, "PropertiesTests.m") AC_MSG_RESULT(yes) ], [ - AC_MSG_RESULT(no) -]) - -AC_MSG_CHECKING(whether Objective C compiler supports optional protocols) -AC_TRY_COMPILE([ - @protocol Proto - @optional - + (void)foo; - @end - - @interface Foo - @end - - @implementation Foo - @end -], [ - [Foo foo]; -], [ - AC_DEFINE(OF_HAVE_OPTIONAL_PROTOCOLS, 1, - [Compiler support for optional protocols]) - AC_MSG_RESULT(yes) -], [ AC_MSG_RESULT(no) ]) AC_MSG_CHECKING(whether Objective C compiler supports blocks) old_OBJCFLAGS="$OBJCFLAGS" @@ -110,11 +69,10 @@ OBJCFLAGS="$OBJCFLAGS -fblocks" AC_TRY_COMPILE([], [ int (^foo)(int bar); foo = ^ (int bar) { return 0; } ], [ - AC_DEFINE(OF_HAVE_BLOCKS, 1, [Compiler support for blocks]) AC_SUBST(BLOCKS_FLAGS, "-fblocks") AC_SUBST(OFBLOCKTESTS_M, "OFBlockTests.m") AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -44,10 +44,26 @@ #endif #ifndef __has_feature # define __has_feature(x) 0 #endif + +#if defined(__clang__) +# define OF_HAVE_PROPERTIES +# define OF_HAVE_OPTIONAL_PROTOCOLS +# define OF_HAVE_FAST_ENUMERATION +#elif defined(__GNUC__) +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) +# define OF_HAVE_PROPERTIES +# define OF_HAVE_OPTIONAL_PROTOCOLS +# define OF_HAVE_FAST_ENUMERATION +# endif +#endif + +#if __has_feature(blocks) +# define OF_HAVE_BLOCKS +#endif #if __has_feature(objc_bool) # undef YES # define YES __objc_yes # undef NO Index: src/objfw-defs.h.in ================================================================== --- src/objfw-defs.h.in +++ src/objfw-defs.h.in @@ -2,21 +2,17 @@ #undef OF_ATOMIC_OPS #undef OF_BIG_ENDIAN #undef OF_COMPILER_TLS #undef OF_FLOAT_BIG_ENDIAN #undef OF_HAVE_ASPRINTF -#undef OF_HAVE_BLOCKS -#undef OF_HAVE_FAST_ENUMERATION #undef OF_HAVE_GCC_ATOMIC_OPS -#undef OF_HAVE_OPTIONAL_PROTOCOLS #undef OF_HAVE_OSATOMIC #undef OF_HAVE_OSATOMIC_64 -#undef OF_HAVE_PROPERTIES #undef OF_HAVE_PTHREADS #undef OF_HAVE_PTHREAD_SPINLOCKS #undef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES #undef OF_HAVE_SCHED_YIELD #undef OF_HAVE_SYS_SELECT_H #undef OF_OBJFW_RUNTIME #undef OF_PLUGINS #undef OF_THREADS #undef SIZE_MAX