jlhaferman@l_eld02.icaen.uiowa.edu (Jeffrey Lawrence Haferman) (03/27/90)
Could anyone give me some pointers on converting a C program to C++? I don't necessarily need to take advantage of the C++ features - I just want to get my C program to compile under C++. What is the minimum that must be done? I have a main program in C which includes several header files and links in some (non-standard) libraries. I don't have source for the libraries, but I'm hoping I just need to modify the header files (external linkage, suspending type checking here and there, etc). I am making some headway on the conversion, but if someone experienced with this could provide some advice, I'd appreciate it. Jeff Haferman internet: jlhaferman@icaen.uiowa.edu Department of Mechanical Engineering University of Iowa Iowa City IA 52240
rfg@ics.uci.edu (Ronald Guilmette) (03/29/90)
In article <1040@ns-mx.uiowa.edu> jlhaferman@l_eld02.icaen.uiowa.edu (Jeffrey Lawrence Haferman) writes: > >Could anyone give me some pointers on converting a C >program to C++? I don't necessarily need to take >advantage of the C++ features - I just want to get my >C program to compile under C++. What is the minimum >that must be done? > >I have a main program in C which includes several header >files and links in some (non-standard) libraries. I >don't have source for the libraries, but I'm hoping I just >need to modify the header files (external linkage, suspending >type checking here and there, etc). > >I am making some headway on the conversion, but if someone >experienced with this could provide some advice, I'd >appreciate it. I think that maybe I should make this posting once a month, so that newcommers don't miss it. I hope that old-timers will forgive me for re-posting this announcement. You're probably all sick of hearing about protoize buy now, but there is obviously an occasional newcommer who hasn't had a chance to see this yet. ------------------------------------------------------------------------- Protoize/Unprotoize ------------------- This is a brief announcement concerning to two free software tools called protoize and unprotoize. Protoize is a tool to assist in the conversion of old-style (K&R) C code to new-style ANSI C code or C++ code (with function prototypes). Unprotoize is a tool to assist in the conversion of new-style ANSI C code to old-style (K&R) C code without function prototypes. Neither of these tools claims to do a complete conversion (there are too many sniggling little incompatabilities) however the bulk of the work (usually more than 90%) in such conversions usually involves function prototypes. This is the part of the job that protoize & unprotoize can perform automatically (leaving you to contend only with the remaining sniggling details). The Protoize and Unprotoize tools have been built specifically for doing these types of conversions on LARGE systems of C source code. They are fairly intelligent and are able to perform conversions of both function definitions and function declarations, and they can do so over entire groups of source files at a time. Protoize can use information gleaned from one source file to update other source files. This capability is most useful when one wants one's include files to contain ANSI C (and/or C++) function prototypes. Protoize is able to automagically insert such prototypes into .h files based upon information it gets from your .c files. Likewise, extern function declarations appearing in one .c file will be converted to prototype form based upon information gathered from the actual function definitions in the same .c source file, or in other .c files. Protoize can also be used with your system's native "source flavor" lint libraries to generate a complete set of fully prototyped "system" include files. Such a set can be useful for catching more function calling errors at compile time. Protoize and unprotoize work in conjunction with the GNU C compiler (GCC) which is used as a front-end information gathering tool. In order to build or use protoize or unprotoize you must also build and use GCC. Protoize, Unprotoize, and GCC are owned and operated by the Free Software Foundation. They are available to all under the terms and conditions of the GNU Public Licence, a copy of which is provided with the source code for GCC. Availability ------------ Protoize/Unprotoize version 1.07 and is now available for anonymous FTP from ics.uci.edu. Size of the protoize-1.07.Z file is 89135 bytes. Protoize/Unprotoize 1.07 can also be obtained via anonymous UUCP from osu-cis. (Contact for UUCP transfer is Karl Kleinpaste <karl@cis.ohio-state.edu>). (European availablity of protoize/unprotoize is described below). On ics.uci.edu, protoize/unprotoize 1.07 can be found as: ~ftp/pub/protoize-1.07.Z ~ftp/pub/protoize-1.07.93.Z Version 1.07 is dramatically better than previous versions. Substantial improvements have been made in robustness and ease-of-use. If you tried protoize/unprotoize before and didn't like them, please try them again. You may be plesantly surprized. This version has been pre-tested by several people on a number of different machines and is belived to be quite portable and reasonably bug free. (My special thanks to all the pre-testers!) As with prior versions, the distribution file is a compressed *patch* file (not a tar file) which should be applied to a pristine set of GCC Version 1.36 source files. (The file protoize-1.07.93.Z is also available for those users now pre-testing GCC 1.36.93. Size is 89029 bytes. That version should also be used for GCC 1.37 until I have a chance to create another patch file just for that version of GCC.) The application of the protoize/unprotoize patches will result in the creation of several new files. Among these "additions" are the file README_PROTOIZE and a common pre-man-page file called proto-unproto.1. The latter file will be preprocessed into two man-page files (called protoize.1 and unprotoize.1) by the (modified) Makefile during a normal build of the (modified) GCC. Because so many things have changed in this version, it is strongly advised that you read the README_PROTOIZE file and the man pages again, even if you have already been using prior versions of protoize/unprotoize. As before, I welcome comments, suggestions, bug reports and (especially) compliments. User suggestions have been the major source of ideas for new features up till now, and I'll try to be receptive if you have a new idea for an additional feature. Please let me know if you use these tools to do a conversion on any large (i.e. >= 100k lines of code) system. Note that when using protoize 1.07 you may occasionally get messages like: please add `extern foobar()' to SYSCALLS.c These messages are an indication that your native "system" include files are not yet in fully prototyped form. For now, you should just ignore these messages. I am now developing a plan whereby protoize will be able to auto- magically create protoized versions of system include files for a variety of systems. This scheme will probably make its debut in v1.08. After that, we can all (finally) get totally protoized. (This will also be a major benefit for C++ users.) ----------------------------------------------------------------------------- European Availability: Two sites are distributing protoize-1.07.Z in Europe: Protoize-1.07.Z can be retrieved by anonymous ftp from mizar.docs.uu.se (130.238.4.1). Contact is Ove Ewerlid <ewerlid@mizar.docs.uu.se>. The files are located in: ~ftp/pub/gnu/protoize-1.07.Z ~ftp/pub/gnu/protoize-1.07.93.Z (Thanks Ove!) --------------------------------------------------------------------- Rijks Universiteit Utrecht (Utrecht University, Department of Computer Science). Contact is Edwin Kremer <edwin@cs.ruu.nl>. It may be obtained either via anonymous FTP or by mail, as follows: * Anon FTP: System: sol.cs.ruu.nl [131.211.80.5] Files: ~ftp/pub/GNU/protoize-1.07.Z ~ftp/pub/GNU/protoize-1.07.93.Z * Mail Server: European sites not having FTP access may retrieve it from the Rijks Universiteit Utrecht by sending an email message to <mail-server@cs.ruu.nl> with contents path <your_valid_return_address> btoa send GNU/protoize-1.07.Z end Leave out the line with "btoa" if you prefer uuencoding. Please use a domain-based return address, or you may loose out.
charlie@genrad.uucp (Charlie D. Havener) (03/29/90)
As an alternative to Protoize there is a cheap and dirty little tool that does not require access to Gnu C compiler sources or lint sources. I wrote an article in the October 1989 'C Users Journal' describing how to use the public domain C grammar, that has been posted to Usenet several times, to build a 'C to C++ Migrator Tool', the article title. The little program runs on Unix systems and PC's. All you need is YACC and FLEX or work alikes. I posted the sources to comp.sources but that is a moderated group and the moderator must have seen enough function prototype makers so it never got onto the net. The 'C User's Journal' will happily send you a PC DOS floppy for $8 with the sources. Floppy #296 phone 913- 841-1631. Charlie@genrad.com GenRad Inc. 300 Baker Ave. Concord Mass. 01742, 508-369-4400 x3302