2

I work in a factory where 80% of our equipment uses an MS-DOS interface. None of our engineers have experience in c/c++ programming, and it was requested we add some features to the machines interface. Our automation group has abandoned the MS-DOS platform in favor of Allen-Bradley controls. I'm feeling ambitious and decided to take on this project, even though I have next to no experience in c/c++.

On to the question:

All of the programming was written and compiled in Turbo C++. I would prefer to use DEV++ for various reasons (ease of use, additional headers, more developed C++ platform, ect.). The problem is the existing programming relies heavily on non-standard headers from TC++. There are 10 or so headers unavailable in DEV++ in the source code, and rewriting the code using more modern constructs is not an option; we would lose what little support we have from our AG, time, ect.

Is there a way I could add all the headers from TC++ to DEV++? For example adding the graphics.h to DEV++ and have it be fully functional? I have tried adding it to the include folder, calling it with #include"graphics.h", and if DEV++ manages to recognize it, it throws a ton of compiling errors because it doesn't recognize the internal commands in the graphics.h file.

Unfortunately I cannot include any example code from this project, due to non-disclosure and copy-write policies.

My programming experience: DABBLE in RSLogigx500,5000 ; Arduino IDE (don't judge) ; Parker 6K ; PanelView ; ~40hrs of self-taught c and c++.

Any help would be much appreciated.

UPDATE Very helpful information. It seems like this isn't going to be possible given how outdated the hardware is and the restrictions I have on this project, but thank you all for your input.

genpfault
  • 51,148
  • 11
  • 85
  • 139
tsmetana
  • 25
  • 3
  • 3
    Dev C++ is outdated and shouldn't be used anymore, consider using Code::Blocks instead. – AntoineB Sep 07 '15 at 06:39
  • C and C++ are not the same language. Be sure to learn recent versions of them (i.e. at least C99 -even better C11- and C++11). Use recent versions of [GCC](http://gcc.gnu.org/) or [Clang/LLVM](http://clang.llvvm.org/) compilers (on the command line) – Basile Starynkevitch Sep 07 '15 at 06:47
  • And standard C11 and C++11 have no graphics. You need some OS specific (or multiplatform) framework, perhaps [Qt](http://qt.io/) or [GTK](http://gtk.org/) or [libsdl](https://www.libsdl.org/) etc etc... BTW, developing on a Linux system could help a lot. You could also consider Web interfaces (e.g. using some HTTP server library like [libonion](http://www.coralbits.com/libonion/)....) – Basile Starynkevitch Sep 07 '15 at 06:51

2 Answers2

4

Most of the headers from old Turbo C are really just the MSDOS API, in a way. So it doesn't make any sense to attempt to use those headers in any other environment and you can't port them to a Windows compiler. Similarly, graphics.h is for a Borland-specific DOS graphics library called BGI and will not work on any other compiler.

It should be noted that old Turbo C++ (I'm assuming version 3.1?) didn't follow the C or C++ standards much. The C++ version it used is completely antique.

Also note that the Dev C++ IDE is outdated and doesn't update the GCC compiler any longer. The CodeBlocks IDE is a better alternative.

Lundin
  • 195,001
  • 40
  • 254
  • 396
  • I don't know which version of TurboC++ the original program was written on, but I have been using version 4. I'm pretty hamstrung with how much I can change the original code, so I may just continue working with TurboC++. From what you said, it doesn't seem like any other IDE/Compiler will let me leave the original code alone. One of the reasons I wanted to move to a different IDE is because TC++ is so ancient. That and even the original code is too long to compile in "one shot", making a compound project is yet another thing I'm going to have to learn. Thank you for your input. – tsmetana Sep 07 '15 at 07:15
3

This is more of a "long comment" than a direct answer to your question, trying to guide you to a better understanding of what MAY be your challenge in your project.

I personally would choose a more "professional" level development tool. Either Eclipse (positives is that this is portable and looks/feels the same whether you use Windows or Linux), XCode (works only on Mac) or Visual Studio (which works only on Windows). These are full featured integrated development environments, and they are all very slick. All of them are free or nearly free.

Compiling OLD code, that is written for DOS into a modern compiler with on a modern OS may be quite a challenge, depending on what the application does and how much in the way of assumptions about it's environment the code is written with:

  • does it assume int is 16 bits
  • does it call direct to DOS to get file info, opening/reading/writing/closing files
  • does it do raw keyboard input
  • does it poke characters and/or pixels directly at the screen
  • does it use far and near pointers, are there driver-like components that interface directly to hardware interrupts

One thing that stands out in your question is the mention of graphics.h, which I believe is very Borland specific. Which means you'll have to write your own replacement functions - either a replacement graphics.h set of functions (I expect most functionality is available in any modern OS, it's more a case of "what is it called and what do I need in order to call that function"). This can be quite a task in itself.

The tricky part here is not only to identify what the code does, but to replace it with similar logic, that does the same thing in your new environment.

And of course, it all depends on what you want to do with the code, how well written it is - is it nicely modular, does each function do one thing and one thing only, or are there functions that "This calculates the value of , and then reads some data from disk, then does some I/O to the screen, and then talks to some external hardware, and because it gets calls frequently, also updates the time on the screen if it has changed".

Mats Petersson
  • 126,704
  • 14
  • 140
  • 227
  • Thank you for your response. Unfortunately there is too much risk in re-writing headers for the original code (it controls expensive equipment, needs to be OSHA cert, ect). Especially if they are re-written by myself... I'll just make friends with TurboC++. – tsmetana Sep 07 '15 at 07:20
  • 1
    @tsmetana: Then you are likely to break your expensive equipment anyway. At least, spend *months* studying C and C++, e.g. by developing and experimenting on a Linux laptop. TurboC++ will only give you bad habits and is not very useful (bad compiler, non standard compliant, etc...) – Basile Starynkevitch Sep 07 '15 at 07:28
  • I'm not familiar with OSHA compliance, but I expect that's NOT something I would take on without: 1) Training in writing code for OSHA, 2) good experience with programming already. – Mats Petersson Sep 07 '15 at 07:33
  • I appreciate the concern. None of the new code will talk to the motion controller on the machines (any code that does requires OSHA Compliance); the headers, however, set up communication to the controller, which is why they won't be modified. Whatever I end up writing will need to be approved many levels above me, just no one else feels like writing it. I have 6 months to come up with working code, figured it wouldn't be a bad idea to learn a new skill. I do have 2 years programming experience, but almost entirely in PLC's, which is a different animal all together. – tsmetana Sep 07 '15 at 08:12