[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: combining a objc header with a c header
From: |
Pascal Bourguignon |
Subject: |
Re: combining a objc header with a c header |
Date: |
Wed, 9 Jan 2002 19:25:47 +0100 (CET) |
Right.
But in that case I would just compile the C code in a separate
library, have the Objective-C code in its own .m files.
Stuff.h
Stuff.c --> Stuff.a
Stuff_fun1(x);
StuffOC.h
StuffOC.c --> StuffOC.a
-[StuffOC meth1:x] { calls Stuff_fun1(x); }
Note the difficulty here that the Objective-C header files are not
named .hm or .hoc, but .h, same than C headers.
Why mess with C-preprocessor? Moreover with separate files per
language, it's easier to write the makefile.
By the way, how would you compile/use this:
------------------(happy.source)----------------------------------------
cat /*dev/null; echo "Happy New Year"\!
cat <<c*/ /*dev/null | cat > /dev/null
c */ () {} /*
c */ main() { cat(); printf("Happy New Year!\n"); } /*
17 format('Happy New Year!')
write (6,17)
stop
end
c*/
------------------------------------------------------------------------
> From: Nicola Pero <n.pero@mi.flashnet.it>
> Date: Wed, 9 Jan 2002 13:51:01 +0000 (GMT)
>
> Sorry for answering late ... problem being that gnu.gnustep.* newsgroups
> are *not* mirrored to the mailing list ... while the mailing list is being
> mirrored on the newsgroups ... so we never read your message.
>
> >I am writing a library in c but I would like to implement a objc wrapper
> >aswell.
> >
> >Is it possible to include in the header file c syntax as well as objc
> >syntax.
> >
> >For example
> >
> >#ifdef COMPILING_C
> >
> >...lots of code...
> >
> >#endif
> >
> >#ifdef COMPILING_OBJC
> >
> >...lots of code...
> >
> >#endif
>
> The Objective-C compiler can compile perfectly well C code ... so the C
> code can be compiled both in C and in Objective-C ... you don't need to
> protect it.
>
> The C compiler can not compile Objective-C code, so you need to protect
> the Objective-C code when you compile in C. You can simply use something
> like
>
> #ifdef __OBJC__
>
> #endif
>
> __OBJC__ is defined by the compiler if and only if it is the Objective-C
> compiler.
(answer: you can run happy.source either thru csh, sh, c or fortran!)
csh happy.source
bash happy.source
c -o happy-c happy.source
f77 -o happy-f happy.source
--
__Pascal_Bourguignon__ (o_ Software patents are endangering
() ASCII ribbon against html email //\ the computer industry all around
/\ and Microsoft attachments. V_/ the world http://lpf.ai.mit.edu/
1962:DO20I=1.100 2001:my($f)=`fortune`; http://petition.eurolinux.org/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/IT d? s++:++(+++)>++ a C+++ UB+++L++++$S+X++++>$ P- L+++ E++ W++
N++ o-- K- w------ O- M++$ V PS+E++ Y++ PGP++ t+ 5? X+ R !tv b++(+)
DI+++ D++ G++ e+++ h+(++) r? y---? UF++++
------END GEEK CODE BLOCK------