delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2006/04/27/15:55:49

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: KTrumpetsRule AT cs DOT com
Message-ID: <397.209602d.318278dc@cs.com>
Date: Thu, 27 Apr 2006 15:43:24 EDT
Subject: question about Objective C
To: djgpp AT delorie DOT com
MIME-Version: 1.0
X-Mailer: CompuServe 2000 32-bit sub 103
X-Spam-Flag: NO
Reply-To: djgpp AT delorie DOT com

I was trying to look at Objective C.  I downloaded all the latest components
via zip picker, installed them all in c:\djgpp.

The program I tried was an example from one of the tutorials on the web.
Here is main.m:

// This will create a printer object, set it's string and tell it to print
#import "printer.h"
void main()
{
    id printer = [[Printer alloc] init];
    [printer addStringValue:"Hello World!"];
    [printer print];
    [printer free];
}

Here is printer.m:

#import "Printer.h"
@implementation Printer
- init
{
    [super init];
    [self clear];
    return self;
}
- addStringValue:(const char*)astring
{
    strcat(buffer, astring);
    return self;
}
- print
{
    printf("%s\n",buffer);
    [self clear];
    return self;
}
- clear
{
    strcpy(buffer, "");
    return self;
}
@end

Here is printer.h:

#import <objc/Object.h>
@interface Printer : Object
{
    char buffer[100];
}
- init;
- addStringValue:(const char*)astring;
- print;
- clear;
@end

Here's what I use to compile the above.  Maybe this is where the problem lies
as I'm not sure how the Objective C switches work.  I downloaded a copy of 
the 4.10 compiler docs and couldn't find much help in them.

main.exe: main.o printer.o
    gcc -o main.exe printer.o

printer.o : printer.m printer.h
    gcc -c -pedantic -ansi -Wno-import -lobjc -fgnu-runtime printer.m

main.o : main.m printer.h
    gcc -c -pedantic -ansi -Wno-import -lobjc -fgnu-runtime main.m

I then get the following error messages.  This is only the tail end of them
as they scroll by to fast to capture them all.

C:/DJGPP/BIN/../lib/gcc/djgpp/4.10/include/objc/hash.h:277: error: expected 
'=',
 ',', ';', 'asm' or '__attribute__' before 'unsigned'
C:/DJGPP/BIN/../lib/gcc/djgpp/4.10/include/objc/hash.h:279: error: expected 
'=',
 ',', ';', 'asm' or '__attribute__' before 'unsigned'
C:/DJGPP/BIN/../lib/gcc/djgpp/4.10/include/objc/hash.h:285: error: expected 
'=',
 ',', ';', 'asm' or '__attribute__' before 'unsigned'
C:/DJGPP/BIN/../lib/gcc/djgpp/4.10/include/objc/hash.h:287: error: expected 
'=',
 ',', ';', 'asm' or '__attribute__' before 'unsigned'
C:/DJGPP/BIN/../lib/gcc/djgpp/4.10/include/objc/hash.h:293: error: expected 
'=',
 ',', ';', 'asm' or '__attribute__' before 'int'
C:/DJGPP/BIN/../lib/gcc/djgpp/4.10/include/objc/hash.h:295: error: expected 
'=',
 ',', ';', 'asm' or '__attribute__' before 'int'
C:/DJGPP/BIN/../lib/gcc/djgpp/4.10/include/objc/hash.h:301: error: expected 
'=',
 ',', ';', 'asm' or '__attribute__' before 'int'
C:/DJGPP/BIN/../lib/gcc/djgpp/4.10/include/objc/hash.h:303: error: expected 
'=',
 ',', ';', 'asm' or '__attribute__' before 'int'
main.m: In function 'main':
main.m:6: warning: return type of 'main' is not 'int'
make.exe: *** [main.o] Error 1

Any help would be appreciated.

Bill
;-))

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019