| delorie.com/archives/browse.cgi | search | 
| X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f | 
| From: | Cesar Rabak <csrabak AT yahoo DOT com DOT br> | 
| Newsgroups: | comp.os.msdos.djgpp | 
| Subject: | Re: question about Objective C | 
| Date: | Thu, 27 Apr 2006 18:31:38 -0300 | 
| Organization: | Aioe.org NNTP Server | 
| Lines: | 95 | 
| Message-ID: | <e2rcue$5va$1@emma.aioe.org> | 
| References: | <397 DOT 209602d DOT 318278dc AT cs DOT com> | 
| NNTP-Posting-Host: | RlVd++5HrKvzofRtoX/5wQ.user.aioe.org | 
| Mime-Version: | 1.0 | 
| X-Complaints-To: | abuse AT aioe DOT org | 
| In-Reply-To: | |
| X-Accept-Language: | pt-br, pt | 
| User-Agent: | Mozilla Thunderbird 1.0.6-6mdk (X11/20050322) | 
| To: | djgpp AT delorie DOT com | 
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp | 
| Reply-To: | djgpp AT delorie DOT com | 
KTrumpetsRule AT cs DOT com escreveu:
> 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()
Change this to:
main()
> {
>     id printer = [[Printer alloc] init];
>     [printer addStringValue:"Hello World!"];
>     [printer print];
>     [printer free];
> }
> 
You use both capitalized 'Printer.h' and lowercase 'printer.h' and this 
will bite you someday.
> 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.
> 
Make the following changes:
> main.exe: main.o printer.o
>     gcc -o main.exe printer.o
       gcc -o main.exe main.o printer.o -lobjc
> 
> printer.o : printer.m printer.h
>     gcc -c -pedantic -ansi -Wno-import -lobjc -fgnu-runtime printer.m
       gcc -c -Wno-import -fgnu-runtime printer.m
> 
> main.o : main.m printer.h
>     gcc -c -pedantic -ansi -Wno-import -lobjc -fgnu-runtime main.m
       gcc -c -Wno-import -fgnu-runtime main.m
> 
[snipped]
Should compile now.
HTH
--
Cesar Rabak
| webmaster | delorie software privacy | 
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |