Re: [MacPorts] #58645: physfs @3.0.1: error: ‘autoreleasepool’ undeclared (was: Physfs fails to build Mac OSX 10.5 Leopard)
MacPorts
noreply at macports.org
Sat Nov 23 21:12:48 UTC 2019
#58645: physfs @3.0.1: error: ‘autoreleasepool’ undeclared
-----------------------------+---------------------------
Reporter: linuxjunkie999 | Owner: (none)
Type: defect | Status: new
Priority: Normal | Milestone:
Component: ports | Version: 2.5.4
Resolution: | Keywords: tiger leopard
Port: physfs |
-----------------------------+---------------------------
Changes (by ryandesign):
* keywords: leopard => tiger leopard
Comment:
> `@autoreleasepool` change to `NSAutoreleasePool;`
That's definitely not the correct fix.
`@autoreleasepool` automatically creates an `NSAutoreleasePool` for the
duration of the block. This notation is required when using Automatic
Reference Counting, and modern macOS requires ARC. This notation also
works correctly on pre-ARC systems, but only if you're using clang from
Xcode 4.2 or later, and your log shows you're not using clang but rather
gcc-4.2. It also shows you're on PowerPC, and we haven't gotten clang to
work on PowerPC yet.
Lacking the ability to use `@autoreleasepool`, the way to get this code to
work on older systems would be to create and destroy the
`NSAutoreleasePool` manually. That is, instead of:
{{{
@autoreleasepool {
...
}
}}}
it would need to be:
{{{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
...
[pool release];
}}}
And since that older style is not compatible with ARC, we would need to
determine at compile time whether `@autoreleasepool` is available and use
the right code for each case.
Your suggested statement `NSAutoreleasePool;` is a no-op: it does nothing.
(`NSAutoreleasePool` is a type; you've just mentioned a type on a line by
itself, without doing anything with that type such as declaring a variable
of that type and assigning something to it.) Your suggestion does not set
up an autorelease pool, so it just results in leaking all the memory that
the autorelease pool should have been releasing.
In any case, we are not the developers of physfs. This is really an issue
that should be reported to the developers of physfs so that they can fix
it. I am not sure how much they care about older systems, but they did in
the 3.0.2 release this year accept some patches from me and Ken to fix
building on 10.7, so they may be interested, especially if the fix can be
provided to them.
--
Ticket URL: <https://trac.macports.org/ticket/58645#comment:3>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list