'NSAutoreleasePool may not respond to' -drain on Ubuntu

I am trying to compile the following Objective-C program on Ubuntu Hardy, but for some reason I am getting warnings.

#import <Foundation/Foundation.h>
int main (int argc, char *argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    NSLog (@"Hello");
    [pool drain];
    return 0;
}

Compiler output:

$ gcc `gnustep-config --objc-flags` -lgnustep-base objc.m
This is gnustep-make 2.0.2. Type 'make print-gnustep-make-help' for help.
Making all for tool LogTest...
 Compiling file objc.m ...
objc.m: In function ‘main’:
objc.m:6: warning: ‘NSAutoreleasePool’ may not respond to ‘-drain’
objc.m:6: warning: (Messages without a matching method signature
objc.m:6: warning: will be assumed to return ‘id’ and accept
objc.m:6: warning: ‘...’ as arguments.)
 Linking tool LogTest ...

Here's the result of execution:

$ ./a.out
2009-06-28 21:38:00.063 a.out[13341] Hello
Aborted

I did:

apt-get install build-essential gnustep gobjc gnustep-make libgnustep-base-dev

How to fix this problem?

+3
source share
3 answers

First, the simple answer: use -releaseinstead . I believe it -drainwas added in 10.4 as an alias for -release, and in 10.5 it got its own GC-specific behavior. This allows you to use the code in 10.5 and work up to 10.4. GNUstep probably doesn't have new features yet.


, - Objective-C Ubuntu, , . , . , GNUstep Objective-C , .

  • Objective-C - , ( ), - . Objective-C , Cocoa . Apple ( ) Mac/iPhone.
  • Apple, , Objective-C. LLVM Clang gcc. ( ) , gcc .
  • GNUstep - , , Apple Apple, . Objective-C Apple ( ) .
  • - Objective-C, . ( , , Objective-C - . , .)

, -, " ", . , , , , , .

+3

, GNUStep, - [NSAutoreleasePool drain] OS X 10.4 IIRC. GNUStep, , .

, "" "". ; "" , , "release" .

+3

In my main application loop using GNUStep:

int main(int argc, const char *argv[])
{
    NSAutoreleasePool *pool;
    AppController *delegate;

    pool = [[NSAutoreleasePool alloc] init];
    // ...
    [pool release];
    return NSApplicationMain (argc, argv);
}
+1
source

Source: https://habr.com/ru/post/1711469/


All Articles