Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Objective-C help
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="bikka" data-source="post: 1240497" data-attributes="member: 202448"><p>Hi everyone,</p><p></p><p>I know there is a lot of threads with this topic but they didnt help me.</p><p>So, I installed the Xcode3 with the gcc 4.2 and created a simple hello world example.</p><p>[code]</p><p>#import <stdio.h></p><p></p><p>int main( int argc, const char *argv[] ) {</p><p> printf( "hello world\n" );</p><p> return 0;</p><p>}</p><p>[/code]</p><p></p><p>Then, I built it with the command:</p><p>[code]</p><p>gcc -lobjc hello.m -o hello</p><p>[/code]</p><p>no problem until here.</p><p>Then, when i tried to run this example:</p><p>[code]</p><p>/* Comments:</p><p> ** Example written by Pascal Bourguignon</p><p> ** return status change by Chris B. Vetter</p><p> ** Added comments in empty {} section by Chris B. Vetter</p><p> ** int main() changed to int main(void) by Dennis Leeuw</p><p> ** from comments by Chris B. Vetter</p><p> */</p><p></p><p>#include <objc/Object.h></p><p></p><p>@interface Greeter:Object</p><p>{</p><p> /* This is left empty on purpose:</p><p> ** Normally instance variables would be declared here,</p><p> ** but these are not used in our example.</p><p> */</p><p>}</p><p></p><p>- (void)greet;</p><p></p><p>@end</p><p></p><p>#include <stdio.h></p><p></p><p>@implementation Greeter</p><p></p><p>- (void)greet</p><p>{</p><p> printf("Hello, World!\n");</p><p>}</p><p></p><p>@end</p><p></p><p>#include <stdlib.h></p><p></p><p>int main(void)</p><p>{</p><p> id myGreeter;</p><p> myGreeter=[Greeter new];</p><p></p><p> [myGreeter greet];</p><p></p><p> [myGreeter free];</p><p> return EXIT_SUCCESS;</p><p>}</p><p>[/code]</p><p>I got this:</p><p>[code]</p><p>MacBikka:Desktop bikka$ gcc -lobjc Greater.m -o Greater</p><p>Greater.m: In function ‘main’:</p><p>Greater.m:40: warning: ‘Greeter’ may not respond to ‘+new’</p><p>Greater.m:40: warning: (Messages without a matching method signature</p><p>Greater.m:40: warning: will be assumed to return ‘id’ and accept</p><p>Greater.m:40: warning: ‘...’ as arguments.)</p><p>Greater.m:44: warning: no ‘-free’ method found</p><p>[/code]</p><p>I got this same errors with others examples. </p><p></p><p>Am I missing something? I think gcc is working fine. Could anyone try to run this example and tell me what happens?</p><p></p><p>thx in advanced!</p></blockquote><p></p>
[QUOTE="bikka, post: 1240497, member: 202448"] Hi everyone, I know there is a lot of threads with this topic but they didnt help me. So, I installed the Xcode3 with the gcc 4.2 and created a simple hello world example. [code] #import <stdio.h> int main( int argc, const char *argv[] ) { printf( "hello world\n" ); return 0; } [/code] Then, I built it with the command: [code] gcc -lobjc hello.m -o hello [/code] no problem until here. Then, when i tried to run this example: [code] /* Comments: ** Example written by Pascal Bourguignon ** return status change by Chris B. Vetter ** Added comments in empty {} section by Chris B. Vetter ** int main() changed to int main(void) by Dennis Leeuw ** from comments by Chris B. Vetter */ #include <objc/Object.h> @interface Greeter:Object { /* This is left empty on purpose: ** Normally instance variables would be declared here, ** but these are not used in our example. */ } - (void)greet; @end #include <stdio.h> @implementation Greeter - (void)greet { printf("Hello, World!\n"); } @end #include <stdlib.h> int main(void) { id myGreeter; myGreeter=[Greeter new]; [myGreeter greet]; [myGreeter free]; return EXIT_SUCCESS; } [/code] I got this: [code] MacBikka:Desktop bikka$ gcc -lobjc Greater.m -o Greater Greater.m: In function ‘main’: Greater.m:40: warning: ‘Greeter’ may not respond to ‘+new’ Greater.m:40: warning: (Messages without a matching method signature Greater.m:40: warning: will be assumed to return ‘id’ and accept Greater.m:40: warning: ‘...’ as arguments.) Greater.m:44: warning: no ‘-free’ method found [/code] I got this same errors with others examples. Am I missing something? I think gcc is working fine. Could anyone try to run this example and tell me what happens? thx in advanced! [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Objective-C help
Top