C to C++

Posted by BluePanther on Sun 07 Jun 2015 09:55 AM — 5 posts, 20,105 views.

United Kingdom #0
So far I've:
Installed build essentials
Forked a Git repository
Git cloned it
Compiled it - failed: no zlib
Installed zlib
Compiled it - success
Started it - failed: wrong shell scripting language, should be bash
Amended startup - crash course in bash and csh!
Start it - success
Mushclient connect to it as Admin - success
In a room, no exits. What? Perhaps I need to search? Nope
Wheres the friendly admin manual? No, there isn't one.
Search Gammon Forum - loads of commands: goto <vnum>
Just need vnum of areas - found
Goto areas - woo hoo!

Now what?
I know: I'll convert it very, very slowly to C++, because although have dabbled with C I've no experience of C++, so I'll get to learn the language!

Renamed .? to .?pp
Amended Makefile - something else to crash learn, sigh
Compiled it again - success
Start it - success
Mushclient connect to it as Admin - success

Now I want to change standard .h (eg stdio.h) to C++ equivalents (drop the .h affix a c), but for those .h without a C++ equivalent I need to surround it with extern "C" { ... }.

So my question is, are the .h required for telnet already C++ compliant or do I need to wrap them? If they are please let me know what gives it away so that I can check zlib myself without hassling you.

Thank you in advance.
United Kingdom #1
Update:

Installed zlib.h has the extern "C" { ... } wrapping when compiled using C++ - nice

Anyone got any information about the telnet headers?
Australia Forum Administrator #2
Try it and see, is my advice. Quite possibly they have it in them.

Quote:

Now I want to change standard .h (eg stdio.h) to C++ equivalents ...


This will be a big job. I'm not saying it can't be done, but a lot of work for fairly little return. You can always convert the files to .cpp and still use the standard IO.
Amended on Sun 07 Jun 2015 09:44 PM by Nick Gammon
USA Global Moderator #3
Quote:
I know: I'll convert it very, very slowly to C++, because although have dabbled with C I've no experience of C++, so I'll get to learn the language!

No you won't. C++ is almost a superset of C (not exactly, but that's another conversation). So almost all C code will compile just fine as C++ with very minor changes. So converting a large amount of working C to C++, even if you can actually get through all of it, will teach you next to nothing important about C++. Working knowledge of templates, class inheritence, constructors/destructors, etc are not things you can pick up from doing a conversion from C to C++, because they won't be necessary to get the code working because the code will work without them.
United Kingdom #4
Quote:
Try it and see, is my advice. Quite possibly they have it in them.

I shall.

Quote:
This will be a big job. I'm not saying it can't be done, but a lot of work for fairly little return. You can always convert the files to .cpp and still use the standard IO.

I'll try it out with one of the source files and make a decision as to carry on or not.

Quote:
I know: I'll convert it very, very slowly to C++, because although have dabbled with C I've no experience of C++, so I'll get to learn the language!

Now wish I hadn't said that - so naive of me.