Xref: utzoo comp.lang.c++:6473 comp.windows.x:18465 gnu.g++:659 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!mips!bridge2!jarthur!uci-ics!rfg From: rfg@ics.uci.edu (Ronald Guilmette) Newsgroups: comp.lang.c++,comp.windows.x,gnu.g++ Subject: Re: X11 and C++ Message-ID: <25D9FE0C.29186@paris.ics.uci.edu> Date: 15 Feb 90 00:55:40 GMT References: <943@imec.UUCP> <25D887FF.273@paris.ics.uci.edu> <29158@brunix.UUCP> Reply-To: rfg@ics.uci.edu (Ronald Guilmette) Organization: UC Irvine Department of ICS Lines: 109 In article <29158@brunix.UUCP> jlv@cs.brown.edu (Jeff Vogel) writes: >In article <25D887FF.273@paris.ics.uci.edu> rfg@ics.uci.edu (Ronald Guilmette) writes: >>In article <943@imec.UUCP> depuydt@imec.be (Francis Depuydt) writes: >>>I would like to use the X11 library functions in my C++ environment. >>>However, some keywords of C++ seem to be used for X11 variables. >>>Are there other incompatibilities? Did some of you experience the same >>>sort of problem, and what is the 'cheapest' solution? >> > >I am all for some tools to let X11 compile with C++. >Incidentally, how did you solve the type checking problem? >Did you create your own header files with all of the >X extern declarations and their parameters (or ...). I guess that I should have been posting my announcements of protoize & unprotoize tools to the comp.windows.x newsgroup also! Some people have obviously missed them! Let me now SHOUT so that ****** EVERYONE ON THE NET CAN HEAR ME ******* There are free tools available (called protoize & unprotoize) which are ultra intelligent tools that use information from your C code source files (that is, both "base" files *and* include files) to convert entire *large* system of K&R C source code (e.g. X11) from good old K&R C code to fully prototyped ANSI C code (or to C++ code). The protoize tool cannot possibly do a full-fledged conversion (too many nit-picking details) but it will do all necessary conversion of function declarations and definitions (in both base files and include files) to prototype format. This work constitutes the bulk of the conversion effort. Other tweeking must be done manually, but protoize can typically do better than 90% of the editing work. A critically important feature of protoize is that it obtains information to do its job from *all* of the files in a given program before it even starts its work. This allows it to do intelligent conversion of function declarations and definitions even across multiple files (and in particular into include files). For example, assume the following files: foo.h: ----------------------------------------------------------------- extern int bar (); ----------------------------------------------------------------- foo.c: ----------------------------------------------------------------- int bar (); typedef struct tricky_case *tricky_p; int bar (i, p) int i; tricky_p p; { ... } ----------------------------------------------------------------- After running protoize over these files, they come out looking like this: foo.h: ----------------------------------------------------------------- extern int bar (int i, tricky_p p); ----------------------------------------------------------------- foo.c: ----------------------------------------------------------------- int bar (int i, tricky_p p); typedef struct tricky_case *tricky_p; int bar (int i, tricky_p p) { ... } ----------------------------------------------------------------- Now you must manually move the typedef for `tricky_p' up into the include file, but there are some people (me included) who would say that good software engineering practices would make you want to do this anyway. After all, if there is a declaration of `bar' in the include file (where it is presumably needed because other files may need to make references to `bar') then by all rights, these other files will probably also need to know about the type called `tricky_p'. Anyway, as you should see from the above example, protoize is capable of automatically generating a fully prototyped set of include files for any large system of old-style (K&R) C code (e.g. X11). Of course, as I have said, there may be a bit of tweeking required afterwards to get these files back into a "legal" form. Protoize/Unprotoize use the GNU C compiler as a "front-end" information gathering tool. (Thus I didn't have to build a whole darn parser!) You must have GCC to make use of protoize/unprotoize. Protoize/Unprotoize (v1.07) are available via anonymous FTP from ics.uci.edu. look for the file protoize-1.07.Z in the ~ftp/pub directory. This is a compressed *patch* file (not a tar file). It must be applied to GCC 1.36. You then must rebuild GCC and read the supplied man pages for protoize/unprotoize. Protoize/Unprotoize 1.07 is also available via anonymous UUCP from osu-cis. I case it ain't obvious, I hope that everyone will convert to using prototypes someday real soon. // rfg