Re: C language in obj-c
Re: C language in obj-c
- Subject: Re: C language in obj-c
- From: Alastair Houghton <email@hidden>
- Date: Wed, 29 Apr 2009 11:25:04 +0100
On 29 Apr 2009, at 11:04, fawad shafi wrote:
may be this question is odd, but i wana use .obj file created in c
language, in objective-c.
is it possible??
It depends what you mean. If you're asking if it's possible to use C
code in a program that uses ObjC, of course. Usually you'd include
the C source code in your project and Xcode will just compile it for
you when you hit Build. Then you use the usual mechanisms to make use
of your C code from your ObjC files (i.e. the "extern" keyword,
function prototypes, header files and so on).
You can, of course, include C code in ObjC files directly, since ObjC
is just a superset of the underlying C language.
If you are asking whether you can use .obj files built by (for
instance) Microsoft's compiler, the answer is no. Microsoft's .obj
files use an extended form of COFF, whereas the .o files generated by
OS X compilers use Mach-O, and while it's theoretically possible that
you could convert a COFF file to Mach-O and feed it through the OS X
linker, the platforms have different ABIs (calling conventions,
structure layout conventions and the like) and so most likely it would
just break.
If you're asking whether it's possible to include an object file in a
project in a general sense, again the answer is yes. You might need
to feed the linker some additional arguments though, to make it link
against the extra object. However, as I say, the object file needs to
be a Mach-O object and not (for instance) a Microsoft .obj file.
Kind regards,
Alastair.
p.s. This type of question is better addressed to xcode-dev.
--
http://alastairs-place.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden