[Bug objc/67455] New: Inheriting from Object doesn't provide alloc, init or new rendering methods usless

2015-09-04 Thread jam.hobson at hotmail dot co.uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67455

Bug ID: 67455
   Summary: Inheriting from Object doesn't provide alloc, init or
new rendering methods usless
   Product: gcc
   Version: 4.8.1
Status: UNCONFIRMED
  Severity: major
  Priority: P3
 Component: objc
  Assignee: unassigned at gcc dot gnu.org
  Reporter: jam.hobson at hotmail dot co.uk
  Target Milestone: ---

I have selected version 4.8.1, but other versions have the same problem

When ever I try to instantiate a class using ClassName *foo = [[ClassName
alloc] init]; or ClassName *foo = [ClassName new]; it tells me that +alloc and
-init or -new don't exist. Other people on the internet are having the same
issues

I know that the objc part of GCC has been updated, the bug may be that there
are no updated documents detailing how to use the new version without using
GNUStep or another runtime.

here is an example of the problem:

code:

#import 
#import 

@interface TestObject : Object
{
int internalInt;
}

- (int)add:(int)anInt;
- (int)subtract:(int)anInt;
- (int)value;

@end


@implementation TestObject

- (id)init
{
if ((self = [super init]))
{
internalInt = 0;
}

return self;
}

- (int)add:(int)anInt
{
internalInt += anInt;
return internalInt;
}

- (int)subtract:(int)anInt
{
internalInt -= anInt;
return internalInt;
}

- (int)value
{
return internalInt;
}

@end


int main(int argc, char** argv)
{
TestObject *aTestObject = [[TestObject alloc] init];
printf("Initial Value: %d\n", [aTestObject value]);
printf("+45 Value: %d\n", [aTestObject add: 45]);
printf("-63 Value: %d\n", [aTestObject subtract: 63]);

[aTestObject add: 103];
printf("+103 Value: %d\n", [aTestObject value]);

return (EXIT_SUCCESS);
}

debug error:
gcc -o main main.m -lobjc

main.m: IN function '-{TestObject init]':
main.m:20:2: warning: 'Object' may not respond to '-init' [enabled by default]
   if ((self = [super init]))
   ^
main.m:20:2: warning: (Messages without a matching method signature [enabled by
default]
main.m:20:2: warning will be assumed to return 'id' and accept [enabled by
default]
main.m:20:2: warning: '...' as arguments.) [enabled by default]
main.m: In function 'main':
   TestObject *aTestObject = [[TestObject alloc] init];
   ^
main.m:51:2: warning: incompatible implicit declaration of built-in function
'printf' [enabled by default]
   printf("Initial Value: %d\n", [aTestObject value]);
   ^


Please help!


[Bug objc/67455] Inheriting from Object doesn't provide alloc, init or new rendering methods usless

2015-09-05 Thread jam.hobson at hotmail dot co.uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67455

--- Comment #2 from James Hobson  ---
Okay. Interesting. Why is it then that many place on the internet indicate that
they do?

http://ubuntuforums.org/showthread.php?t=1064045
http://wiki.codeblocks.org/index.php?title=Installing_Objective-C_Compiler#Test_Build
https://en.wikibooks.org/wiki/Objective-C_Programming/syntax


Are they using something different?



[Bug objc/67455] Inheriting from Object doesn't provide alloc, init or new rendering methods usless

2015-09-05 Thread jam.hobson at hotmail dot co.uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67455

--- Comment #3 from James Hobson  ---
Or more importantly, how can I write an +alloc method?