Converting C++ to C
Some early implementations of C++ operated as preprocessors that emitted C code. Is there any current tool that will do that? I didn't recognize any such option in the g++ manpage, although I suppose it's possible that one of the -fdump-tree- options would come close enough. Reason: I want to make what I think would be a fairly minor change to a small (1100-line) C++ program, but I don't know C++ -- only C -- and I don't understand the program well enough to mess with it. I suspect I would be able to figure out an equivalent C program. In case it matters, I'm using FreeBSD 8.1. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Converting C++ to C
per...@pluto.rain.com wrote: Some early implementations of C++ operated as preprocessors that emitted C code. Is there any current tool that will do that? I didn't recognize any such option in the g++ manpage, although I suppose it's possible that one of the -fdump-tree- options would come close enough. Reason: I want to make what I think would be a fairly minor change to a small (1100-line) C++ program, but I don't know C++ -- only C -- and I don't understand the program well enough to mess with it. I suspect I would be able to figure out an equivalent C program. In case it matters, I'm using FreeBSD 8.1. One of the lists recently (maybe 2/3 weeks ago) carried a thread listing many C compilers past present. It started by discussing Clang V. GCC I can't remember which list, I don't think it was questions@ maybe hackers@ or current@. Cheers, Julian -- Julian Stacey, BSD Unix Linux C Sys Eng Consultants Munich http://berklix.com Reply below not above, cumulative like a play script, indent with . Format: Plain text. Not HTML, multipart/alternative, base64, quoted-printable. Mail from @yahoo dumped @berklix. http://berklix.org/yahoo/ ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Converting C++ to C
On Fri, Feb 24, 2012 at 4:37 AM, per...@pluto.rain.com wrote: Some early implementations of C++ operated as preprocessors that emitted C code. Is there any current tool that will do that? I didn't recognize any such option in the g++ manpage, although I suppose it's possible that one of the -fdump-tree- options would come close enough. Reason: I want to make what I think would be a fairly minor change to a small (1100-line) C++ program, but I don't know C++ -- only C -- and I don't understand the program well enough to mess with it. I suspect I would be able to figure out an equivalent C program. In case it matters, I'm using FreeBSD 8.1. http://www.comeaucomputing.com/ http://www.comeaucomputing.com/tryitout/ http://www.comeaucomputing.com/faqs/genfaq.html#ccompiler http://stackoverflow.com/questions/737257/code-convert-from-c-to-c Thank you very much . Mehmet Erol Sanliturk ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Converting C++ to C
On 02/24/12 22:07, Julian H. Stacey wrote: per...@pluto.rain.com wrote: Some early implementations of C++ operated as preprocessors that emitted C code. Is there any current tool that will do that? I didn't recognize any such option in the g++ manpage, although I suppose it's possible that one of the -fdump-tree- options would come close enough. Reason: I want to make what I think would be a fairly minor change to a small (1100-line) C++ program, but I don't know C++ -- only C -- and I don't understand the program well enough to mess with it. I suspect I would be able to figure out an equivalent C program. In case it matters, I'm using FreeBSD 8.1. One of the lists recently (maybe 2/3 weeks ago) carried a thread listing many C compilers past present. It started by discussing Clang V. GCC I can't remember which list, I don't think it was questions@ maybe hackers@ or current@. Questions. I started it... :) ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Converting C++ to C
Julian H. Stacey j...@berklix.com wrote; per...@pluto.rain.com wrote: Reason: I want to make what I think would be a fairly minor change to a small (1100-line) C++ program, but I don't know C++ -- only C -- and I don't understand the program well enough to mess with it. I suspect I would be able to figure out an equivalent C program. In case it matters, I'm using FreeBSD 8.1. One of the lists recently (maybe 2/3 weeks ago) carried a thread listing many C compilers past present. It started by discussing Clang V. GCC I can't remember which list, I don't think it was questions@ maybe hackers@ or current@. There _was_ a recent discussion on 'questions' -- I'm the 'guilty party' responsible for naming a lot of the 'historical' ones. That aside, for the OP: C code generated from C++ will _not_ be very readable. Basically, -everything- in C++ would get turned into a function invocation in the generated C. With the _name_ of each such function having an encoded representation of the type of each argument to that function (see 'function name mangling). And the simple elementary data types tend to end up as something like: **struct foo {bar value; (*(**struct foo)baz())[];}. Some of the mayhem: _everything_ is 'double indirect' pointers, to support run-time automatic garbage collection; 'methods' of acting on data elements are pointers to functions, embedded in the data-element structure, even basic 'four function calculator' arithmetic ops (they can be 'overlaid' to do differnt things on different data types -- the '+' operator may mean 'concatenation' when applied to two strings, or '+=' maay mean 'append item to list, in the contest of 'list += item', even though both would *still* mean 'addition' when used with numeric items.) One would be far better off spending some time to learn the basics of C++ syntax -- to be able to 'read' the existing code and understand what it's doing. After that, if what you want to modiy -is- truely a 'minor' change, adding some 'C-tyee' code to implement it is probably not that bad. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org