discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fast enumeration


From: Nicola Pero
Subject: Re: Fast enumeration
Date: Fri, 4 Feb 2011 18:27:21 +0100


If you refer to for(id x in y) syntax, I believe you just need to use a compiler with objc2.0 support, as well as a sufficiently recent runtime.

That, and support for the fast enumeration protocol in Base collections. This exists at least in base-1.20.1.

This doesn't actually resolve the question, though, it just restates it.

Which compilers support [this aspect of] Objective-C 2.0 outside of Apple's platforms? Neither gcc nor clang provide sufficiently
comprehensive release notes to determine this sort of thing reliably.

GCC up to 4.5 does not support it. GCC 4.6 (currently frozen, preparing for release) does support it.

The GCC 4.6 release notes (http://gcc.gnu.org/gcc-4.6/changes.html) contain a complete list of all the changes in the Objective-C
compiler in GCC 4.6.  In particular, they state:

"The Objective-C 2.0 fast enumeration syntax is supported in Objective- C. This is currently not yet available in Objective-C++. Fast enumeration requires support in the runtime, and such support has been added to the GNU Objective-C runtime library
(shipped with GCC)."

I hope these release notes are clear and comprehensive enough ;-)

How do I detect, at build time, which runtime I'm using, and precisely which version of what runtime has the necessary support? This is the sort of information one might expect to find on the ObjC2_FAQ wiki page, but one doesn't (and it's probably out of date anyway).

Basically, my choices are:
* Test a rather large set of compiler, runtime and library versions together under a VM.
* Hope that someone (i.e. David) imparts Secret Lore.
* Continue to use slow enumeration extensively throughout Oolite for the next couple of years, except on 64-bit Mac OS X.

In the case of GCC, you can simply check for the macro __GNU_LIBOBJC__ which is defined only by the GNU Objective-C runtime shipped with GCC 4.6 (and onwards) and by no other runtime.

If that macro is #defined, you have fast enumeration support in the compiler+runtime. If not, you don't unless you're using clang+libobjc2 I guess, which should be possible to check using another macro.

Thanks

PS: Unfortunately, you are asking for a stable release, and GCC 4.6 hasn't been released yet, and you need gnustep-base from trunk (soon to be released too) to use GCC 4.6. In a couple of months, you'll have it in stable releases :-)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]