Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Codewarrior Windows > Re: Objective C...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 5 Topic 295 of 318
Post > Topic >>

Re: Objective C/C++

by "marcus" <marcus7171@[EMAIL PROTECTED] > Nov 29, 2005 at 05:42 PM

Hi!

Yes, it is the objective-c keywords that are not recognized by the MW
compiler. When -- or if -- I manage to pass the compilation phase I
will start to deal with the runtime issue. (-:

Sample objective-c code (compiles with gcc main.m -o x -lobjc):

// --------------------------------------------------------
#include <objc/objc.h> //<objc/Object.h>
#include <stdio.h>

@[EMAIL PROTECTED]
 SmallTest //: Object
- (const char *) description;
@[EMAIL PROTECTED]
 SmallTest
- (const char *) description
{
  return ("I program and therefore I am");
}
@[EMAIL PROTECTED]
 main(int argc, const char *argv[])
{
  SmallTest *obj = [SmallTest new];
  printf ("%s\n", [obj description]);
  return (0);
}
// --------------------------------------------------------
(I had to uncomment the inclusion of <objc/Object.h> because it uses
c++ keywords for message functions etc. The headers comes from the GCC
runtime.)

The code above fails with error:

  Error: declaration syntax error
  main.m line 4   @[EMAIL PROTECTED]
 SmallTest //: Object

  Error: declaration syntax error
  main.m line 6   @[EMAIL PROTECTED]
  Error: declaration syntax error
  main.m line 13   @[EMAIL PROTECTED]
  Error: undefined identifier 'SmallTest'
  main.m line 17   SmallTest *obj = [SmallTest new];

  Error: expression syntax error
  main.m line 18   printf ("%s\n", [obj description]);

If I start with

  #pragma objective_c on

the MW compiler reports the warning

  Warning: illegal #pragma
  main.m line 1   #pragma objective_c on

I noticed also another warning reported by mwcc, that's it using the
compiler from the command line:

### mwcc.exe Driver Warning:
#   No file mapping matches 'main.m' (unrecognized file contents or
filename extension);treating as source text
..
..
..

Thus I wonder if I need to activate something like a "file mapping"? Or
is the Objective c feature is disabled on the x86 compiler?




 5 Posts in Topic:
Objective C/C++
"marcus" <ma  2005-11-28 17:40:58 
Re: Objective C/C++
"marcus" <ma  2005-11-29 17:42:15 
Re: Objective C/C++
Ron L <ron.liechty@[EM  2005-11-30 21:16:33 
Re: Objective C/C++
"marcus" <ma  2005-11-30 22:17:38 
Re: Objective C/C++
"toby" <toby  2005-12-01 15:25:42 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat May 17 5:56:07 CDT 2008.