[comp.windows.x] OBJECTIVE-C COMPATIBLE WITH XLIB AND XTLIB?

ISSLCK@NUSVM.BITNET (Law Chee Keong) (12/20/88)

Can anyone tell me if I can use Objective-C to call Xlib and Xtlib
functions.

If yes, does that imply that it is possible to link code written in
Objective-C with object code or library files written in C?

Has anyone done the above yet?

Thanks very much!!

loffredd@rpics (Dave Loffredo) (12/22/88)

In article <8812200759.AA06418@ATHENA.MIT.EDU> ISSLCK@NUSVM.BITNET 
(Law Chee Keong) writes:

>Can anyone tell me if I can use Objective-C to call Xlib and Xtlib
>functions.

	I am starting a project which may require doing exactly
	this and see no possible incompatibility.   There
	is really nothing in either package (to my knowledge)
	that precludes their mutual use.

>If yes, does that imply that it is possible to link code written in
>Objective-C with object code or library files written in C?

	Of course it is!  I do it all the time! The Objective-C
	compiler just performs a precompile into "straight" C.  
	When you eventually link modules, you are just linking 
	normal ".o" files ... same as always. 

-----------------------------------------------------------------------------
David T. Loffredo			| "These are MY views, 
Email:	loffredd@turing.cs.rpi.edu	|  and you can't have them!"
Phone:	(518) 274-6366  (home) 		|

kap121@ztivax.UUCP (Thomas Oeser) (01/03/89)

In article <8812200759.AA06418@ATHENA.MIT.EDU>, ISSLCK@NUSVM.BITNET (Law Chee Keong) writes:
	> 
	> Can anyone tell me if I can use Objective-C to call Xlib and Xtlib
	> functions.
	> 
	> If yes, does that imply that it is possible to link code written in
	> Objective-C with object code or library files written in C?
	> 
	> Has anyone done the above yet?
	> 
	> Thanks very much!!

Yes, you can; yes, it is possible; yes, we did...

Objective-C claims to be a real superset of C. This implies, that every
C source is automatically an Objective-C source, too, and, thus, fully
compatible with the rest of your sources using the message syntax and `id'
data type available for Objective-C only.

Since the Objective-C compiler converts your sources into plain C (try using
the -Retain option!) and then runs the normal C compiler (have a look at the
command objcc, its a shell script), your question reduces to simply can I link 
onject modules generated from C sources with onject modules generated from C
sources...

This is related to the follow-up article #2974:
	>...I found there is actually a clash between the Objective-C compiler
	>and the X.h file....nested typedef...

Does the output come from the Objective-C preprocessor (OBJCC:....) or does
this occure when compiling the generated C source with the normal C compiler
(c1:...)? If 1) then that's a bug in Objective-C (and you may have a look at
the lex/yacc scripts). If 2) ... :-). BTW, we have no problems with this 
particular include file (however, we are still using X11R2).

Now some words about our work:
We did an implementation of output device independent graphical objects, that
can be used by (interactive) graphical applications to generate and
maintain(!!) their images. These objects live in an abstract coordinate space,
they can be accessed and modified at any time (both geometrical and
non-geomtrical aspects), they can be duplicated and transformed, etc.
In addition, we implemented a (tree) structuring scheme for these objects to
give aid in storing and administrate objects to application programs.
By the simple method "draw" sent to either an object or to any node in the
ordering structure the object(s) try to render itself to a current output
medium. The output medium is again an object and hides the system dependencies
from the output device independent objects. So, an application program simply
creates an instance of the proper output medium object class to output to
whatever device it wants (we currently have such objects classes for X,
PostScript, another local printer format, etc.), and, thus, is able to output 
to both a X window and a PostScript printer etc. without any conditional 
statement within its source.

To the future:
The widgets are a pretty nice model and work fine for interfacing with the
human user. They follow a real object oriented concept, but they are not
written in Objective-C :-(. It is worthwile to think about, how to interface
to widgets (or something like that) in terms of Objective-C.


Thomas Oeser

------------------------------------------------------------------------------
ARPA:		kap121@ztivax.siemens.com
UUCP:		kap121@ztivax.uucp (may work only in Europe...)
Postal mail:	Siemens AG, K Sys Ap 121, Otto-Hahn-Ring 6, P.O. Box 830951,
		D-8000 Munich 83, West Germany
Phone:		+ 49 (89) 636-47537
FAX:		+ 49 (89) 636-41477
------------------------------------------------------------------------------